Extract sf geometries from ggplot_build layer data as GeoJSON strings
Source:R/sf_utils.R
extract_sf_geometries.RdExtracts the sfc geometry column from a data.frame produced by
ggplot_build()$data[[i]], normalizes CRS to WGS84 unconditionally (per D-11),
and serializes each geometry as a GeoJSON geometry string via
geojsonsf::sfc_geojson() (per D-10).
Details
gg2d3's public sf renderer accepts polygon, point, and line geometry
families for geom_sf() and projected-anchor annotation support for
geom_sf_text() and geom_sf_label(). Missing CRS emits
"geom_sf layer has missing CRS; coordinates will be serialized as-is".
Unsupported, empty, invalid, or missing geometries emit
"geom_sf layer skipped %d unsupported, empty, invalid, or missing geometries"
and are skipped before rendering.