sf_geojson | R Documentation |
Converts 'sf' objects to GeoJSON
sf_geojson( sf, atomise = FALSE, simplify = TRUE, digits = NULL, factors_as_string = TRUE )
sf |
simple feature object |
atomise |
logical indicating if the sf object should be converted into a vector of GeoJSON objects |
simplify |
logical indicating if sf objects without property columns should simplify
( |
digits |
integer specifying the number of decimal places to round numerics.
numeric values are coorced using |
factors_as_string |
logical indicating if factors should be treated as strings. Defaults to TRUE. |
vector of GeoJSON
## Not run: library(sf) sf <- sf::st_sf(geometry = sf::st_sfc(list(sf::st_point(c(0,0)), sf::st_point(c(1,1))))) sf$id <- 1:2 sf_geojson(sf) sf_geojson(sf, atomise = T) ls <- st_linestring(rbind(c(0,0),c(1,1),c(2,1))) mls <- st_multilinestring(list(rbind(c(2,2),c(1,3)), rbind(c(0,0),c(1,1),c(2,1)))) sfc <- st_sfc(ls,mls) sf <- st_sf(sfc) sf_geojson( sf ) sf_geojson( sf, simplify = FALSE ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.