From 1596a92c2b994bcebf95990ff0c5fe7f74c628a4 Mon Sep 17 00:00:00 2001 From: Krzysztof Dyba <35004826+kadyb@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:58:52 +0200 Subject: [PATCH] upload `12_GeoJSON` --- html/12_GeoJSON.html | 1706 ++++++++++++++++++++++++++++++++++++++ notebooks/12_GeoJSON.Rmd | 46 + 2 files changed, 1752 insertions(+) create mode 100644 html/12_GeoJSON.html create mode 100644 notebooks/12_GeoJSON.Rmd diff --git a/html/12_GeoJSON.html b/html/12_GeoJSON.html new file mode 100644 index 0000000..d6046ba --- /dev/null +++ b/html/12_GeoJSON.html @@ -0,0 +1,1706 @@ + + + + + + + + + + + + + +Fast loading and saving of GeoJSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +

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. +

+
+ +Code + +
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
+
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/notebooks/12_GeoJSON.Rmd b/notebooks/12_GeoJSON.Rmd new file mode 100644 index 0000000..4aa0464 --- /dev/null +++ b/notebooks/12_GeoJSON.Rmd @@ -0,0 +1,46 @@ +--- +title: "Fast loading and saving of GeoJSON" +output: + html_document: + df_print: paged +--- + +** +The [{yyjsonr}](https://github.com/coolbutuseless/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. +** + +
+Code + +```{r message=FALSE} +library("sf") +library("yyjsonr") +options(timeout = 600) # connection timeout +``` + +```{r message=FALSE} +## 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** + +```{r} +system.time( sf::write_sf(data, "test.geojson") ) +system.time( yyjsonr::write_geojson_file(data, "test.geojson") ) +``` + +**Data loading** + +```{r} +system.time( sf::read_sf("test.geojson") ) +system.time( yyjsonr::read_geojson_file("test.geojson") ) +``` + +