I am trying to display several zipcodes (thus polygons...) on a leaflet
map. Data is available as a geojson
file here. I chose as an example some zip c
You just needed to not parse the geojson to a data.frame, fromJSON(url, FALSE)
library(jsonlite)
library(leaflet)
url <- "https://raw.githubusercontent.com/openseattle/seattle-boundaries/master/data/zip-codes.geojson"
geojson <- fromJSON(url, simplifyVector = FALSE)
leaflet() %>%
addTiles() %>%
addGeoJSON(geojson) %>%
setView(lng = -122.2, lat = 47.6, zoom = 10)
addGeoJSON()
will also accept a string, e.g.
geojson_str <- paste0(readLines(url), collapse = "")
then pass that to addGeoJSON