The {yyjsonr} package
offers fast loading and saving of GeoJSON files compared to the GDAL
used by, for example, {sf}
and {terra}
.
However, GDAL has more features like filtering based on criteria.
library("sf")
library("yyjsonr")
options(timeout = 600) # connection timeout
## download dataset
url = "https://github.com/paleolimbot/geoarrow-data/releases/download/v0.0.1/nshn_land_poly.gpkg"
download.file(url, "nshn_land_poly.gpkg", mode = "wb")
data = read_sf("nshn_land_poly.gpkg") # 24037 polygons x 11 attributes
data = st_transform(data, "EPSG:4326") # transform to WGS84
Data saving
system.time( sf::write_sf(data, "test.geojson") )
## user system elapsed
## 62.80 1.10 63.92
system.time( yyjsonr::write_geojson_file(data, "test.geojson") )
## user system elapsed
## 1.09 0.71 2.21
Data loading
system.time( sf::read_sf("test.geojson") )
## user system elapsed
## 22.14 1.67 23.83
system.time( yyjsonr::read_geojson_file("test.geojson") )
## user system elapsed
## 0.67 0.51 1.17