diff --git a/README.Rmd b/README.Rmd index 3e764ea..f1116fe 100644 --- a/README.Rmd +++ b/README.Rmd @@ -88,7 +88,7 @@ library(frictionless) The content of the data package can be consulted using `read_package()`. ```{r} -b3data_package <- read_package("https://zenodo.org/records/15181098/files/datapackage.json") +b3data_package <- read_package("https://zenodo.org/records/15211029/files/datapackage.json") b3data_package ``` @@ -105,7 +105,7 @@ For non-tabular resources (e.g. spatial or raster data), use packages like `sf` ```{r} mgrs10_belgium <- sf::st_read( - "https://zenodo.org/records/15181098/files/mgrs10_refgrid_belgium.geojson", + "https://zenodo.org/records/15211029/files/mgrs10_refgrid_belgium.gpkg", quiet = TRUE) head(mgrs10_belgium) ``` diff --git a/README.md b/README.md index f8f6654..ac5dc51 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ like `sf` or `terra` directly. ``` r mgrs10_belgium <- sf::st_read( - "https://zenodo.org/records/15181098/files/mgrs10_refgrid_belgium.geojson", + "https://zenodo.org/records/15181098/files/mgrs10_refgrid_belgium.gpkg", quiet = TRUE) head(mgrs10_belgium) #> Simple feature collection with 6 features and 1 field diff --git a/data/b3data_package/datapackage.json b/data/b3data_package/datapackage.json index fc8f5b9..c23677c 100644 --- a/data/b3data_package/datapackage.json +++ b/data/b3data_package/datapackage.json @@ -1,7 +1,7 @@ { "name": "b3data", - "id": "https://doi.org/10.5281/zenodo.15181098", - "version": "0.1.0", + "id": "https://doi.org/10.5281/zenodo.15211029", + "version": "0.1.2", "resources": [ { "name": "bird_cube_belgium_mgrs10", @@ -11,7 +11,7 @@ "mediatype": "text/csv", "encoding": "utf-8", "title": "Occurrence cube for birds in Belgium (MGRS 10 km)", - "description": "Occurrence cube for birds in Belgium between 2000 en 2024. The taxonomical resolution is 'species' and the temporal resolution is 'year' Spatial aggregation is done using the MGRS grid at 10 km scale. Only grid cells that fall within the 10 km MGRS reference grid for mainland Belgium (see b3data: `mgrs10_refgrid_belgium.geojson`) are included.", + "description": "Occurrence cube for birds in Belgium between 2000 en 2024. The taxonomical resolution is 'species' and the temporal resolution is 'year' Spatial aggregation is done using the MGRS grid at 10 km scale. Only grid cells that fall within the 10 km MGRS reference grid for mainland Belgium (see b3data: `mgrs10_refgrid_belgium.gpkg`) are included.", "sources": [ { "title": "GBIF Occurrence Download", @@ -64,10 +64,10 @@ }, { "name": "mgrs10_refgrid_belgium", - "path": "mgrs10_refgrid_belgium.geojson", - "format": "geojson", + "path": "mgrs10_refgrid_belgium.gpkg", + "format": "gpkg", "title": "MGRS 10 km reference grid Belgium", - "description": "MGRS 10 km reference grid for the mainland of Belgium.", + "description": "MGRS 10 km reference grid for the mainland of Belgium. EPSG:32631 (WGS 84 / UTM zone 31N).", "licenses": [ { "name": "CC0-1.0", diff --git a/inst/en_gb.dic b/inst/en_gb.dic index 7da38ca..95d0065 100644 --- a/inst/en_gb.dic +++ b/inst/en_gb.dic @@ -1,12 +1,14 @@ Daele EEA GeoJSON +GeoPackage Havenlaan Langeraert MGRS NC Rproj Teirlinckgebouw +WGS cff dic gb diff --git a/source/R/download_occ_cube.R b/source/R/download_occ_cube.R index cc9469b..749377d 100644 --- a/source/R/download_occ_cube.R +++ b/source/R/download_occ_cube.R @@ -6,8 +6,10 @@ download_occ_cube <- function(sql_query, file, path, overwrite = FALSE) { # Stop if overwrite = FALSE and file does not exist file_path <- file.path(path, file) if (file.exists(file_path) && !overwrite) { - message(paste("File already exists. Reading existing file.", - "Set `overwrite = TRUE` to overwrite file.", sep = "\n")) + message( + paste("File already exists. Reading existing file.", + "Set `overwrite = TRUE` to overwrite file.", sep = "\n") + ) occ_cube <- readr::read_csv(file = file_path, show_col_types = FALSE) @@ -34,7 +36,8 @@ download_occ_cube <- function(sql_query, file, path, overwrite = FALSE) { readr::write_csv( x = occ_cube, file = file_path, - append = FALSE) + append = FALSE + ) # Return tibble return(occ_cube) diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 459896e..097c36a 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -39,7 +39,7 @@ Add spatial data resources to b3data frictionless data package. # Methods -This report focuses on adding spatial resources (e.g. GeoJSON, raster) to the **b3data** frictionless data package. +This report focuses on adding spatial resources (e.g. GeoPackage, raster) to the **b3data** frictionless data package. ## Source Data @@ -57,7 +57,7 @@ Example: Each dataset includes the following metadata (see: [Frictionless resource spec](https://docs.ropensci.org/frictionless/articles/data-resource.html#properties-implementation)): -- **format**: e.g. `geojson` +- **format**: e.g. `gpkg` - **title**: e.g. `"MGRS 10 km reference grid for Belgium"` - **description**: concise explanation of content - **sources**: source if applicable @@ -77,20 +77,22 @@ ggplot() + geom_sf(data = utm10_bel) ``` Clean data and transform cell codes to MGRS. +Convert to EPSG:32631 (WGS 84 / UTM zone 31N). ```{r} mgrs10_refgrid_belgium <- utm10_bel %>% select(utm_tag = TAG, geometry) %>% mutate(mgrscode = ifelse(grepl("^[A-G]", utm_tag), paste0("31U", utm_tag), paste0("32U", utm_tag))) %>% - select(mgrscode, geometry) + select(mgrscode, geometry) %>% + st_transform(32631) ``` Write to data package and add metadata. ```{r} st_write(mgrs10_refgrid_belgium, - file.path(package_path, "mgrs10_refgrid_belgium.geojson"), + file.path(package_path, "mgrs10_refgrid_belgium.gpkg"), delete_dsn = TRUE) ``` @@ -101,25 +103,28 @@ b3data_package <- read_package(file.path(package_path, "datapackage.json")) # Add resource to data package mgrs10_resource <- list( name = "mgrs10_refgrid_belgium", - path = "mgrs10_refgrid_belgium.geojson", - format = "geojson", + path = "mgrs10_refgrid_belgium.gpkg", + format = "gpkg", title = "MGRS 10 km reference grid Belgium", - description = "MGRS 10 km reference grid for the mainland of Belgium.", + description = paste("MGRS 10 km reference grid for the mainland of Belgium.", + "EPSG:32631 (WGS 84 / UTM zone 31N)."), licenses = list(list( name = "CC0-1.0", path = "https://creativecommons.org/publicdomain/zero/1.0/", title = "Creative Commons Zero v1.0 Universal" - )) - ) + )) +) b3data_package <- add_manual_resource( - b3data_package, mgrs10_resource, replace = TRUE) + b3data_package, mgrs10_resource, replace = TRUE +) # Write package to directory write_package( package = b3data_package, directory = package_path, - compress = TRUE) + compress = TRUE +) ``` ## EEA 100 km reference grid Europe diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index 2e34a16..4cbeb53 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -38,7 +38,7 @@ Create [frictionless](https://docs.ropensci.org/frictionless/) data package with # Methods This report focuses on creating the **b3data** frictionless data package for tabular datasets. -A separate report adds spatial resources (e.g. GeoJSON, raster) to the same data package. +A separate report adds spatial resources (e.g. GeoPackage, raster) to the same data package. ## Data Package Overview @@ -134,7 +134,7 @@ bird_cube_belgium_mgrs10_full <- download_occ_cube( ) ``` -We only select the grid cells that belong to the MGRS 10 km reference grid for the mainland of Belgium (see b3data `mgrs10_refgrid_belgium.geojson`). +We only select the grid cells that belong to the MGRS 10 km reference grid for the mainland of Belgium (see b3data `mgrs10_refgrid_belgium.gpkg`). ```{r} # Read reference grid @@ -166,8 +166,9 @@ b3data_package <- create_package() %>% "the temporal resolution is 'year'", "Spatial aggregation is done using the MGRS grid at 10 km scale.", "Only grid cells that fall within the 10 km MGRS reference grid for", - "mainland Belgium (see b3data: `mgrs10_refgrid_belgium.geojson`) are", - "included."), + "mainland Belgium (see b3data: `mgrs10_refgrid_belgium.gpkg`) are", + "included." + ), sources = list(list( title = "GBIF Occurrence Download", path = "https://doi.org/10.15468/dl.y3wpwk" @@ -176,7 +177,7 @@ b3data_package <- create_package() %>% name = "CC0-1.0", path = "https://creativecommons.org/publicdomain/zero/1.0/", title = "Creative Commons Zero v1.0 Universal" - )) + )) ) ``` @@ -193,10 +194,10 @@ b3data_package <- append(b3data_package, c(name = "b3data"), after = 0) b3data_package <- append(b3data_package, - c(id = "https://doi.org/10.5281/zenodo.15181098"), + c(id = "https://doi.org/10.5281/zenodo.15211029"), after = 1) b3data_package <- append(b3data_package, - c(version = "0.1.0"), + c(version = "0.1.2"), after = 2) # Warning: append() drops the custom datapackage class. @@ -215,5 +216,6 @@ dir.create(package_path, showWarnings = FALSE, recursive = TRUE) write_package( package = b3data_package, directory = package_path, - compress = TRUE) + compress = TRUE +) ```