Converts `sf` objects to GeoJSON
sf_geojson(
sf,
atomise = FALSE,
simplify = TRUE,
digits = NULL,
factors_as_string = TRUE
)simple feature object
logical indicating if the sf object should be converted into a vector of GeoJSON objects
logical indicating if sf objects without property columns should simplify
(TRUE) into a vector of GeoJSON, or return a Featurecollection with
empty property fields (FALSE). If atomise is TRUE this argument is ignored.
integer specifying the number of decimal places to round numerics.
numeric values are coorced using as.integer, which may round-down the value you supply.
Default is NULL - no rounding
logical indicating if factors should be treated as strings. Defaults to TRUE.
vector of GeoJSON
if (FALSE) { # \dontrun{
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 )
} # }