R: JSONファイルの使用法, R, jsonlite, geojsonio, leaflet

JavaScriptの標準的形式であるJSON(JavaScript Object Notation)で多くのデータが公開されています。

JSONの使用方法についてわかったことを順次メモします。

 

I.地図にpolygonを重ねる

 

参考にした文書

 

How to download NY state all County data in R for leaflet map

 

スクリプトの説明

 

 

 

次に同様のスクリプトがありますが、エラーがでてじっこうできていません。

 

Working with GeoJSON & TopoJSON

 

スクリプト

 

library(leaflet)
library(jsonlite)
library(geojsonio)
# read json from http://eric.clst.org/Stuff/USGeoJSON
geo.usa <- geojsonio::geojson_read("/Downloads/gz_2010_us_050_00_500k.json", what = "sp")
# show names
names(geo.usa)
# you learn the FIPS code of Genesee that should be located in NY state from
# https://www.nrcs.usda.gov/wps/portal/nrcs/detail/national/home/?cid=nrcs143_013697
# search the number of NY state
geo.usa[grepl("36037", geo.usa$GEO_ID), ]$STATE
# select the data of NY state
nyc <- geo.usa[geo.usa$STATE == 36, ] # show the map leaflet(nyc) %>%
addTiles() %>%
addPolygons()
 

to be continued

Please follow and like us:

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.