From 0bcfd82749459b75f8ad844bb5d2e556bb2afc1e Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 11:53:31 +0200 Subject: [PATCH 01/15] ignore raw data --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2cca830..df1e0b1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,10 +16,9 @@ *.shx *.xls* *_files -*.csv *.gz -*.zip docs libs output renv/library +data/raw From cc3fe9b9a71c6e969222c1fd7d3f46eb5a792290 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 13:48:47 +0200 Subject: [PATCH 02/15] create r markdown report --- source/add_spatial_resources.Rmd | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 source/add_spatial_resources.Rmd diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd new file mode 100644 index 0000000..1bcb645 --- /dev/null +++ b/source/add_spatial_resources.Rmd @@ -0,0 +1,39 @@ +--- +title: "Add spatial resources to b3data data package" +author: "Ward Langeraert" +date: "`r Sys.Date()`" +output: + html_document: + code_folding: hide + toc: true + toc_float: true + toc_collapsed: true +editor_options: + chunk_output_type: console +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +```{r, warning=FALSE, message=FALSE} +# Load packages +library(tidyverse) # Data wrangling and visualisation +library(frictionless) # Create frictionless data package +library(sf) # Spatial objects + +# Data path and create directory if necessary +data_path <- here::here("data", "raw") +dir.create(data_path, showWarnings = FALSE, recursive = TRUE) + +out_path <- here::here("data", "processed") +dir.create(out_path, showWarnings = FALSE, recursive = TRUE) +``` + +# Goal + +Add spatial data resources to b3data frictionless data package. + +# Methods + +... From b2e6d65a69c43c62602a0f62ddb00b47474f17ad Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 13:49:03 +0200 Subject: [PATCH 03/15] remove redundant code --- source/create_b3data_package.Rmd | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index 77c0546..e2defe2 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -28,9 +28,6 @@ source(here::here("source", "R", "download_occ_cube.R")) # Data path and create directory if necessary data_path <- here::here("data", "raw") dir.create(data_path, showWarnings = FALSE, recursive = TRUE) - -out_path <- here::here("data", "processed") -dir.create(out_path, showWarnings = FALSE, recursive = TRUE) ``` # Goal From 73f90e8a13c3a27875ab12d2cf7f5bb9ae3d3da5 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 13:53:48 +0200 Subject: [PATCH 04/15] add structure to report --- source/add_spatial_resources.Rmd | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 1bcb645..2dc60a6 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -36,4 +36,17 @@ Add spatial data resources to b3data frictionless data package. # Methods -... +- process data -> save as geojson + +- add to package + +- metadata + +# Datasets +## UTM 10 Km grid Belgium + +## EEA 100 km grid Europe + +> Coming soon + +# Write package From e4d1611cf72ddcfeaea2ac1ba6f10c93951e9143 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 14:52:53 +0200 Subject: [PATCH 05/15] select grid cells based on reference grid --- data/b3data_package/datapackage.json | 2 +- source/create_b3data_package.Rmd | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/data/b3data_package/datapackage.json b/data/b3data_package/datapackage.json index c8464fb..461d0df 100644 --- a/data/b3data_package/datapackage.json +++ b/data/b3data_package/datapackage.json @@ -10,7 +10,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.", + "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.", "sources": ["GBIF Occurrence Download", "https://doi.org/10.15468/dl.y3wpwk"], "licenses": [" CC BY-NC 4.0", "https://creativecommons.org/licenses/by-nc/4.0/", "Creative Commons Attribution-NonCommercial 4.0 International"], "schema": { diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index e2defe2..c61c89c 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -21,6 +21,7 @@ knitr::opts_chunk$set(echo = TRUE) library(tidyverse) # Data wrangling and visualisation library(frictionless) # Create frictionless data package library(rgbif) # Create occurrence cubes from GBIF data +library(sf) # Spatial objects # Source functions source(here::here("source", "R", "download_occ_cube.R")) @@ -36,8 +37,8 @@ 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. +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. ## Data Package Overview @@ -130,7 +131,7 @@ bird_cube_query <- "SELECT # nolint end # Download and load cube -bird_cube_belgium_mgrs10 <- download_occ_cube( +bird_cube_belgium_mgrs10_full <- download_occ_cube( sql_query = bird_cube_query, file = "bird_cube_belgium_mgrs10.csv", path = data_path, @@ -138,6 +139,22 @@ bird_cube_belgium_mgrs10 <- 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`). + +```{r} +# Read reference grid +utm10_bel <- st_read(file.path(data_path, "utm10_bel.shp")) + +# Visualise +ggplot() + geom_sf(data = utm10_bel) +``` + +```{r} +# Only select grid cells from reference grid +bird_cube_belgium_mgrs10 <- bird_cube_belgium_mgrs10_full %>% + filter(substr(mgrscode, 4, nchar(mgrscode)) %in% utm10_bel$TAG) +``` + We create the package and add the dataset. ```{r} @@ -150,7 +167,10 @@ b3data_package <- create_package() %>% "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."), + "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."), sources = c( title = "GBIF Occurrence Download", path = "https://doi.org/10.15468/dl.y3wpwk" From 5496b1b2fc5ac769caccfe338d731d4596a121f3 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 14:53:17 +0200 Subject: [PATCH 06/15] add methods --- source/add_spatial_resources.Rmd | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 2dc60a6..39bc604 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -36,16 +36,38 @@ Add spatial data resources to b3data frictionless data package. # Methods -- process data -> save as geojson +This report focuses on adding spatial resources (e.g. GeoJSON, raster) to the **b3data** frictionless data package. -- add to package +## Source Data -- metadata +Spatial data need to be saved locally in the data package directory and then added manually to the descriptor file using `append()`. +We provide the reference grids for the occurrence cubes in the data package following this naming convention: + +``` +resource_name = "refgrid" +``` + +Example: +`mgrs10_refgrid_belgium` → MGRS 10 km reference grid Belgium + +## Resource-level Metadata + +Each dataset includes the following metadata (see: [Frictionless resource spec](https://docs.ropensci.org/frictionless/articles/data-resource.html#properties-implementation)): + +- **profile**: `spatial-data-resource` +- **format**: e.g. `geojson` +- **title**: e.g. `"MGRS 10 km reference grid for Belgium"` +- **description**: concise explanation of content +- **sources**: source if applicable +- **licenses**: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) # Datasets -## UTM 10 Km grid Belgium +## MGRS 10 Km reference grid Belgium + + + -## EEA 100 km grid Europe +## EEA 100 km reference grid Europe > Coming soon From 2390c8923dc4154e707d04e30cf328ff291a38ca Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 14:53:32 +0200 Subject: [PATCH 07/15] load grid data belgium --- source/add_spatial_resources.Rmd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 39bc604..dde85a3 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -64,7 +64,13 @@ Each dataset includes the following metadata (see: [Frictionless resource spec]( # Datasets ## MGRS 10 Km reference grid Belgium +```{r} +# Read reference grid +utm10_bel <- st_read(file.path(data_path, "utm10_bel.shp")) +# Visualise +ggplot() + geom_sf(data = utm10_bel) +``` ## EEA 100 km reference grid Europe From 4a4f112dd7c88346263407b741e42762525eb796 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 15:12:37 +0200 Subject: [PATCH 08/15] create mgrs tags --- source/add_spatial_resources.Rmd | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index dde85a3..0cfefdd 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -64,6 +64,8 @@ Each dataset includes the following metadata (see: [Frictionless resource spec]( # Datasets ## MGRS 10 Km reference grid Belgium +Load the data. + ```{r} # Read reference grid utm10_bel <- st_read(file.path(data_path, "utm10_bel.shp")) @@ -72,6 +74,16 @@ utm10_bel <- st_read(file.path(data_path, "utm10_bel.shp")) ggplot() + geom_sf(data = utm10_bel) ``` +Clean data and transform cell codes to MGRS. + +```{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) +``` + ## EEA 100 km reference grid Europe From 573e532f00e20366df2eda27ade5860c4863f897 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 15:12:44 +0200 Subject: [PATCH 09/15] clean code --- source/create_b3data_package.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index c61c89c..af4bc5f 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -152,7 +152,7 @@ ggplot() + geom_sf(data = utm10_bel) ```{r} # Only select grid cells from reference grid bird_cube_belgium_mgrs10 <- bird_cube_belgium_mgrs10_full %>% - filter(substr(mgrscode, 4, nchar(mgrscode)) %in% utm10_bel$TAG) + filter(substring(mgrscode, 4) %in% utm10_bel$TAG) ``` We create the package and add the dataset. From 53045085bf0d01119ad44c225826a329b9dcd3e0 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 15:37:17 +0200 Subject: [PATCH 10/15] add geojson --- data/b3data_package/datapackage.json | 13 ++++++-- source/add_spatial_resources.Rmd | 44 +++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/data/b3data_package/datapackage.json b/data/b3data_package/datapackage.json index 461d0df..884bb5f 100644 --- a/data/b3data_package/datapackage.json +++ b/data/b3data_package/datapackage.json @@ -12,7 +12,7 @@ "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.", "sources": ["GBIF Occurrence Download", "https://doi.org/10.15468/dl.y3wpwk"], - "licenses": [" CC BY-NC 4.0", "https://creativecommons.org/licenses/by-nc/4.0/", "Creative Commons Attribution-NonCommercial 4.0 International"], + "licenses": ["CC BY-NC 4.0", "https://creativecommons.org/licenses/by-nc/4.0/", "Creative Commons Attribution-NonCommercial 4.0 International"], "schema": { "fields": [ { @@ -49,12 +49,21 @@ } ] } + }, + { + "name": "mgrs10_refgrid_belgium", + "path": "mgrs10_refgrid_belgium.geojson", + "profile": "spatial-data-resource", + "format": "geojson", + "title": "MGRS 10 Km reference grid Belgium", + "description": "MGRS 10 Km reference grid for the mainland of Belgium.", + "licenses": ["CC0 1.0", "https://creativecommons.org/publicdomain/zero/1.0/", "Creative Commons Zero v1.0 Universal"] } ], "title": "b3data: Data resources for the b3verse", "description": "This data package contains data resources to be used across the b3verse (https://docs.b-cubed.eu/guides/b3verse/). This includes example datasets (occurrence cubes) as well as spatial resources like reference grids or raster data.", "keywords1": "data cubes", - "licenses.name": " CC BY-NC 4.0", + "licenses.name": "CC BY-NC 4.0", "version": "0.1.0", "sources.title": "b3data-scripts", "contributors.title": "Ward Langeraert", diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 0cfefdd..6d8f4c6 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -26,8 +26,8 @@ library(sf) # Spatial objects data_path <- here::here("data", "raw") dir.create(data_path, showWarnings = FALSE, recursive = TRUE) -out_path <- here::here("data", "processed") -dir.create(out_path, showWarnings = FALSE, recursive = TRUE) +package_path <- here::here("data", "b3data_package") +dir.create(package_path, showWarnings = FALSE, recursive = TRUE) ``` # Goal @@ -84,9 +84,45 @@ mgrs10_refgrid_belgium <- utm10_bel %>% select(mgrscode, geometry) ``` +Write to data package and add metadata. + +```{r} +st_write(mgrs10_refgrid_belgium, + file.path(package_path, "mgrs10_refgrid_belgium.geojson"), + append = FALSE) +``` + +```{r} +if (FALSE) { + # Read package + b3data_package <- read_package(file.path(package_path, "datapackage.json")) + + # Add spatial resources manually + b3data_package$resources <- append(b3data_package$resources, list( + list( + name = "mgrs10_refgrid_belgium", + path = "mgrs10_refgrid_belgium.geojson", + profile = "spatial-data-resource", + format = "geojson", + title = "MGRS 10 Km reference grid Belgium", + description = "MGRS 10 Km reference grid for the mainland of Belgium.", + licenses = c( + name = "CC0 1.0", + path = "https://creativecommons.org/publicdomain/zero/1.0/", + title = "Creative Commons Zero v1.0 Universal" + ) + ) + )) + + # Write package to directory + # Write package to directory + write_package( + package = b3data_package, + directory = package_path, + compress = TRUE) +} +``` ## EEA 100 km reference grid Europe > Coming soon - -# Write package From cd26b17595654947adc8a99fe051f4d56109f2fd Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 15:37:42 +0200 Subject: [PATCH 11/15] correct license spelling --- source/create_b3data_package.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index af4bc5f..b1db517 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -176,7 +176,7 @@ b3data_package <- create_package() %>% path = "https://doi.org/10.15468/dl.y3wpwk" ), licenses = c( - name = " CC BY-NC 4.0", + name = "CC BY-NC 4.0", path = "https://creativecommons.org/licenses/by-nc/4.0/", title = "Creative Commons Attribution-NonCommercial 4.0 International" ) @@ -217,7 +217,7 @@ b3data_package <- append(b3data_package, b3data_package <- append( b3data_package, c(licenses = c( - name = " CC BY-NC 4.0", + name = "CC BY-NC 4.0", path = "https://creativecommons.org/licenses/by-nc/4.0/", title = "Creative Commons Attribution-NonCommercial 4.0 International" )), From 800eec757bc46b2e98e89c6f9b3196e9036258fa Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 15:38:39 +0200 Subject: [PATCH 12/15] ignore geojson --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index df1e0b1..a6f64cf 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ *.xls* *_files *.gz +*.geojson docs libs output From a7b351008bb9c1ce1fbcd5afb74f4e824dd76704 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 16:37:22 +0200 Subject: [PATCH 13/15] create function to manually add resource to package --- source/R/add_manual_resource.R | 23 +++++++++++++ source/add_spatial_resources.Rmd | 59 ++++++++++++++++---------------- 2 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 source/R/add_manual_resource.R diff --git a/source/R/add_manual_resource.R b/source/R/add_manual_resource.R new file mode 100644 index 0000000..78400f5 --- /dev/null +++ b/source/R/add_manual_resource.R @@ -0,0 +1,23 @@ +add_manual_resource <- function(package, new_resource, replace = TRUE) { + if (replace) { + # Filter out any resource with same name or path + package$resources <- Filter(function(res) { + !(res$name == new_resource$name && res$path == new_resource$path) + }, package$resources) + } else { + # If not overwriting, check for duplicates and warn + conflict <- any(vapply(package$resources, function(res) { + res$name == new_resource$name && res$path == new_resource$path + }, logical(1))) + + if (conflict) { + warning(paste("Resource with same name and path already exists and", + "`replace = FALSE`. Skipping.")) + return(package) + } + } + + # Append new resource + package$resources <- append(package$resources, list(new_resource)) + return(package) +} diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 6d8f4c6..6fe0ea4 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -22,6 +22,9 @@ library(tidyverse) # Data wrangling and visualisation library(frictionless) # Create frictionless data package library(sf) # Spatial objects +# Source functions +source(here::here("source", "R", "add_manual_resource.R")) + # Data path and create directory if necessary data_path <- here::here("data", "raw") dir.create(data_path, showWarnings = FALSE, recursive = TRUE) @@ -89,38 +92,36 @@ Write to data package and add metadata. ```{r} st_write(mgrs10_refgrid_belgium, file.path(package_path, "mgrs10_refgrid_belgium.geojson"), - append = FALSE) + delete_dsn = TRUE) ``` ```{r} -if (FALSE) { - # Read package - b3data_package <- read_package(file.path(package_path, "datapackage.json")) - - # Add spatial resources manually - b3data_package$resources <- append(b3data_package$resources, list( - list( - name = "mgrs10_refgrid_belgium", - path = "mgrs10_refgrid_belgium.geojson", - profile = "spatial-data-resource", - format = "geojson", - title = "MGRS 10 Km reference grid Belgium", - description = "MGRS 10 Km reference grid for the mainland of Belgium.", - licenses = c( - name = "CC0 1.0", - path = "https://creativecommons.org/publicdomain/zero/1.0/", - title = "Creative Commons Zero v1.0 Universal" - ) - ) - )) - - # Write package to directory - # Write package to directory - write_package( - package = b3data_package, - directory = package_path, - compress = TRUE) -} +# Read package +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", + profile = "spatial-data-resource", + format = "geojson", + title = "MGRS 10 Km reference grid Belgium", + description = "MGRS 10 Km reference grid for the mainland of Belgium.", + licenses = c( + 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) + +# Write package to directory +write_package( + package = b3data_package, + directory = package_path, + compress = TRUE) ``` ## EEA 100 km reference grid Europe From 94e27bd28ef9cdf3beefe7c1489bb3bff20768be Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 16:55:59 +0200 Subject: [PATCH 14/15] fix list indentation descriptor file --- data/b3data_package/datapackage.json | 60 ++++++++++++++++++---------- source/add_spatial_resources.Rmd | 2 +- source/create_b3data_package.Rmd | 30 +++++++------- 3 files changed, 56 insertions(+), 36 deletions(-) diff --git a/data/b3data_package/datapackage.json b/data/b3data_package/datapackage.json index 884bb5f..1cfb066 100644 --- a/data/b3data_package/datapackage.json +++ b/data/b3data_package/datapackage.json @@ -11,8 +11,15 @@ "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.", - "sources": ["GBIF Occurrence Download", "https://doi.org/10.15468/dl.y3wpwk"], - "licenses": ["CC BY-NC 4.0", "https://creativecommons.org/licenses/by-nc/4.0/", "Creative Commons Attribution-NonCommercial 4.0 International"], + "sources": { + "title": "GBIF Occurrence Download", + "path": "https://doi.org/10.15468/dl.y3wpwk" + }, + "licenses": { + "name": "CC BY-NC 4.0", + "path": "https://creativecommons.org/licenses/by-nc/4.0/", + "title": "Creative Commons Attribution-NonCommercial 4.0 International" + }, "schema": { "fields": [ { @@ -57,28 +64,39 @@ "format": "geojson", "title": "MGRS 10 Km reference grid Belgium", "description": "MGRS 10 Km reference grid for the mainland of Belgium.", - "licenses": ["CC0 1.0", "https://creativecommons.org/publicdomain/zero/1.0/", "Creative Commons Zero v1.0 Universal"] + "licenses": { + "name": "CC0 1.0", + "path": "https://creativecommons.org/publicdomain/zero/1.0/", + "title": "Creative Commons Zero v1.0 Universal" + } } ], "title": "b3data: Data resources for the b3verse", "description": "This data package contains data resources to be used across the b3verse (https://docs.b-cubed.eu/guides/b3verse/). This includes example datasets (occurrence cubes) as well as spatial resources like reference grids or raster data.", - "keywords1": "data cubes", - "licenses.name": "CC BY-NC 4.0", + "keywords": ["data cubes", "b3verse", "frictionless", "biodiversity"], + "licenses": { + "name": "CC BY-NC 4.0", + "path": "https://creativecommons.org/licenses/by-nc/4.0/", + "title": "Creative Commons Attribution-NonCommercial 4.0 International" + }, "version": "0.1.0", - "sources.title": "b3data-scripts", - "contributors.title": "Ward Langeraert", - "contributors.path": "https://orcid.org/0000-0002-5900-8109", - "contributors.email": "ward.langeraert@inbo.be", - "contributors.role": "author", - "contributors.organization": "Research Institute for Nature and Forest (INBO)", - "contributors.title.1": "Toon Van Daele", - "contributors.path.1": "https://orcid.org/0000-0002-1362-853X", - "contributors.role.1": "contributor", - "contributors.organization.1": "Research Institute for Nature and Forest (INBO)", - "sources.path": "https://github.com/b-cubed-eu/b3data-scripts", - "licenses.path": "https://creativecommons.org/licenses/by-nc/4.0/", - "licenses.title": "Creative Commons Attribution-NonCommercial 4.0 International", - "keywords2": "b3verse", - "keywords3": "frictionless", - "keywords4": "biodiversity" + "sources": { + "title": "b3data-scripts", + "path": "https://github.com/b-cubed-eu/b3data-scripts" + }, + "contributors": [ + { + "title": "Ward Langeraert", + "path": "https://orcid.org/0000-0002-5900-8109", + "email": "ward.langeraert@inbo.be", + "role": "author", + "organization": "Research Institute for Nature and Forest (INBO)" + }, + { + "title": "Toon Van Daele", + "path": "https://orcid.org/0000-0002-1362-853X", + "role": "contributor", + "organization": "Research Institute for Nature and Forest (INBO)" + } + ] } diff --git a/source/add_spatial_resources.Rmd b/source/add_spatial_resources.Rmd index 6fe0ea4..5309169 100644 --- a/source/add_spatial_resources.Rmd +++ b/source/add_spatial_resources.Rmd @@ -107,7 +107,7 @@ mgrs10_resource <- list( format = "geojson", title = "MGRS 10 Km reference grid Belgium", description = "MGRS 10 Km reference grid for the mainland of Belgium.", - licenses = c( + licenses = list( name = "CC0 1.0", path = "https://creativecommons.org/publicdomain/zero/1.0/", title = "Creative Commons Zero v1.0 Universal" diff --git a/source/create_b3data_package.Rmd b/source/create_b3data_package.Rmd index b1db517..f0c0ec9 100644 --- a/source/create_b3data_package.Rmd +++ b/source/create_b3data_package.Rmd @@ -171,11 +171,11 @@ b3data_package <- create_package() %>% "Only grid cells that fall within the 10 km MGRS reference grid for", "mainland Belgium (see b3data: `mgrs10_refgrid_belgium.geojson`) are", "included."), - sources = c( + sources = list( title = "GBIF Occurrence Download", path = "https://doi.org/10.15468/dl.y3wpwk" ), - licenses = c( + licenses = list( name = "CC BY-NC 4.0", path = "https://creativecommons.org/licenses/by-nc/4.0/", title = "Creative Commons Attribution-NonCommercial 4.0 International" @@ -210,45 +210,47 @@ b3data_package <- append( "resources like reference grids or raster data." )), after = 4) -b3data_package <- append(b3data_package, - c(keywords = c("data cubes", "b3verse", "frictionless", - "biodiversity")), - after = 5) b3data_package <- append( b3data_package, - c(licenses = c( + c(keywords = list(list( + "data cubes", "b3verse", "frictionless", "biodiversity" + ))), + after = 5) +b3data_package <- append( + b3data_package, + c(licenses = list(list( name = "CC BY-NC 4.0", path = "https://creativecommons.org/licenses/by-nc/4.0/", title = "Creative Commons Attribution-NonCommercial 4.0 International" - )), + ))), after = 6) b3data_package <- append(b3data_package, c(version = "0.1.0"), after = 7) b3data_package <- append( b3data_package, - c(sources = c( + c(sources = list(list( title = "b3data-scripts", path = "https://github.com/b-cubed-eu/b3data-scripts" - )), + ))), after = 8) b3data_package <- append( b3data_package, - c(contributors = c( - c( + c(contributors = list(list( + list( title = "Ward Langeraert", path = "https://orcid.org/0000-0002-5900-8109", email = "ward.langeraert@inbo.be", role = "author", organization = "Research Institute for Nature and Forest (INBO)" ), - c( + list( title = "Toon Van Daele", path = "https://orcid.org/0000-0002-1362-853X", role = "contributor", organization = "Research Institute for Nature and Forest (INBO)" ) - )), + ))), after = 9) # Warning: append() drops the custom datapackage class. From 940c7e1d850c9728eec94de973e649b74a3210f9 Mon Sep 17 00:00:00 2001 From: Ward Langeraert Date: Wed, 9 Apr 2025 17:04:26 +0200 Subject: [PATCH 15/15] add order of execution --- README.Rmd | 16 ++++++++++++++++ README.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.Rmd b/README.Rmd index 26a1750..d411896 100644 --- a/README.Rmd +++ b/README.Rmd @@ -46,6 +46,22 @@ This repository contains scripts to create the b3data [frictionless](https://doc This code is developed in context of **T5.5** of the [B-Cubed project](https://b-cubed.eu/). +## Order of execution + +Follow the steps below to run the scripts in a logical order. + +**1.** `create_b3data_package.Rmd` + +- creates the data package +- adds tabular resources +- writes data package + +**2.** `add_spatial_resources.Rmd` + +- loads data package +- adds spatial resources +- writes data package + ## 📦 The `b3data` data package - **Name**: `b3data` diff --git a/README.md b/README.md index e94df17..d1f406b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,22 @@ on [Zenodo](https://zenodo.org/). This code is developed in context of **T5.5** of the [B-Cubed project](https://b-cubed.eu/). +## Order of execution + +Follow the steps below to run the scripts in a logical order. + +**1.** `create_b3data_package.Rmd` + +- creates the data package +- adds tabular resources +- writes data package + +**2.** `add_spatial_resources.Rmd` + +- loads data package +- adds spatial resources +- writes data package + ## 📦 The `b3data` data package - **Name**: `b3data`