Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

leafletとRでAEDの場所をプロットしてみる

Last updated at Posted at 2015-12-13

はじめに

leafletとは?
-> 雑に言うとmap描画のためのjsライブラリ

※kazutanさんの記事が分かりやすいです。(丸投げ)
https://rpubs.com/kazutan/leaflet_slide

とにかくやってみよう!

ライブラリのインストールと動作確認

install.packages("leaflet")
library(leaflet)
# 豊島区を中央として地図描画
leaflet() %>% 
     addTiles() %>% 
     setView(lng=139.715405,lat=35.732459,zoom=14)

スクリーンショット 2015-12-13 0.15.01.png

豊島区のAEDの場所をインポート&プロットする

LinkDataの豊島区AED設置場所より
1-12行目を消去し、タブをカンマに置換後にインポート

aed <- read.csv("AED_list_toshima.csv",header=F)
part_aed <- aed[c(2,3,4,13,14)]
# 列名を変更する
colnames(part_aed) <- c("name","address","place","lat","lng")
# leafletにピンをプロットする
leaflet(part_aed) %>% addTiles() %>% addMarkers(lng=~lng,lat=~lat)

出来ました。簡単すぎる。
スクリーンショット 2015-12-13 10.37.14.png

ポップアップを当ててみる

leaflet(part_aed) %>%
  addTiles() %>%
  addMarkers(lng=~lng,lat=~lat) %>%
  addPopups(lng=~lng,lat=~lat,popup=~name)

スクリーンショット 2015-12-13 10.56.38.png

もちろんズームもOK!
スクリーンショット 2015-12-13 10.58.01.png

困った時のヘルプ

leaflet公式のドキュメントでもOKですが、
基本的にはrに組み込まれるヘルプで良いと思います。

help(leaflet)
help(addPopups)
help(popupOptions)
# とかとか・・

以上!!

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?