View source: R/sp_to_geojson.R
sp_to_geojson | R Documentation |
Convert an R spatial polygons object to a GeoJSON string that can be used in
geojson_layer
. The spatial classes are provided by the
sp
package.
sp_to_geojson(sp)
sp |
A |
A string containing unparsed GeoJSON.
This function will write a GeoJSON file to the temporary directory created by R, but this file will be deleted when the R session ends.
if(require(USAboundaries)) { # Boundaries of the United States of America in 1800 us <- us_boundaries(as.Date("1800-01-01")) us_geojson <- sp_to_geojson(us) cartographer(region = "United States") %>% geojson_layer(data = us_geojson, clickable = TRUE, label = "US 1800") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.