-1
# From http://eric.clst.org/Stuff/USGeoJSON and
# https://en.wikipedia.org/wiki/List_of_United_States_counties_and_county_equivalents
nycounties <- geojsonio::geojson_read("json/nycounties.geojson",
what = "sp")
# Or use the rgdal equivalent:
# nycounties <- rgdal::readOGR("json/nycounties.geojson", "OGRGeoJSON")
pal <- colorNumeric("viridis", NULL)
leaflet(nycounties) %>%
addTiles() %>%
addPolygons(stroke = FALSE, smoothFactor = 0.3, fillOpacity = 1,
fillColor = ~pal(log10(pop)),
label = ~paste0(county, ": ", formatC(pop, big.mark = ","))) %>%
addLegend(pal = pal, values = ~log10(pop), opacity = 1.0,
labFormat = labelFormat(transform = function(x) round(10^x)))
以上代码复制自https://rstudio.github.io/leaflet/json.html。如何在R下载NY州所有郡县数据用于传单地图
我有想法如何在代码需要下载纽约州郡数据(或者换句话说,如何生产nycounties.geojson文件)
我去了这两个网站在第一两点意见但未能将美国纽约州的数据纳入整个数据中。