Closed SymbolixAU closed 6 years ago
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"))
library(microbenchmark)
microbenchmark(
sf = {
nc_poly <- sf::st_cast( nc, to = "POLYGON")
geo_poly <- geojsonsf::sf_geojson( nc_poly )
},
geojsonsf = {
geo_sf <- geojsonsf:::rcpp_sf_to_geojson_downcast( nc )
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# sf 16.019968 16.952798 20.264359 17.283295 19.396397 31.669338 5
# geojsonsf 2.348934 2.597222 3.203101 2.847933 3.017071 5.204344 5
even using geojsonsf
to to down-cast to GeoJOSN, then back to sf
is performant.
microbenchmark(
sf = {
nc_poly <- sf::st_cast( nc, to = "POLYGON")
geo_poly <- geojsonsf::sf_geojson( nc_poly )
},
geojsonsf = {
geo_sf <- geojsonsf:::rcpp_sf_to_geojson_downcast( nc )
nc2 <- geojsonsf::geojson_sf( geo_sf )
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# sf 13.75293 14.42003 16.96273 14.93394 15.38814 26.31861 5
# geojsonsf 10.78687 11.34112 11.60321 11.63283 11.75583 12.49937 5
Moving this into mapdeck & spatialwidget
Similar to
expand_geometries
, have asimplify_multi
argument to simplify geometries?TODO