Skip to content

Commit e4d1611

Browse files
committed
select grid cells based on reference grid
1 parent 73f90e8 commit e4d1611

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

data/b3data_package/datapackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"mediatype": "text/csv",
1111
"encoding": "utf-8",
1212
"title": "Occurrence cube for birds in Belgium (MGRS 10 km)",
13-
"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.",
13+
"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.",
1414
"sources": ["GBIF Occurrence Download", "https://doi.org/10.15468/dl.y3wpwk"],
1515
"licenses": [" CC BY-NC 4.0", "https://creativecommons.org/licenses/by-nc/4.0/", "Creative Commons Attribution-NonCommercial 4.0 International"],
1616
"schema": {

source/create_b3data_package.Rmd

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ knitr::opts_chunk$set(echo = TRUE)
2121
library(tidyverse) # Data wrangling and visualisation
2222
library(frictionless) # Create frictionless data package
2323
library(rgbif) # Create occurrence cubes from GBIF data
24+
library(sf) # Spatial objects
2425
2526
# Source functions
2627
source(here::here("source", "R", "download_occ_cube.R"))
@@ -36,8 +37,8 @@ Create [frictionless](https://docs.ropensci.org/frictionless/) data package with
3637

3738
# Methods
3839

39-
This report focuses on creating the **b3data** Frictionless data package for **tabular datasets**.
40-
A separate report adds **spatial resources** (e.g. GeoJSON, raster) to the same data package.
40+
This report focuses on creating the **b3data** frictionless data package for tabular datasets.
41+
A separate report adds spatial resources (e.g. GeoJSON, raster) to the same data package.
4142

4243
## Data Package Overview
4344

@@ -130,14 +131,30 @@ bird_cube_query <- "SELECT
130131
# nolint end
131132
132133
# Download and load cube
133-
bird_cube_belgium_mgrs10 <- download_occ_cube(
134+
bird_cube_belgium_mgrs10_full <- download_occ_cube(
134135
sql_query = bird_cube_query,
135136
file = "bird_cube_belgium_mgrs10.csv",
136137
path = data_path,
137138
overwrite = FALSE
138139
)
139140
```
140141

142+
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`).
143+
144+
```{r}
145+
# Read reference grid
146+
utm10_bel <- st_read(file.path(data_path, "utm10_bel.shp"))
147+
148+
# Visualise
149+
ggplot() + geom_sf(data = utm10_bel)
150+
```
151+
152+
```{r}
153+
# Only select grid cells from reference grid
154+
bird_cube_belgium_mgrs10 <- bird_cube_belgium_mgrs10_full %>%
155+
filter(substr(mgrscode, 4, nchar(mgrscode)) %in% utm10_bel$TAG)
156+
```
157+
141158
We create the package and add the dataset.
142159

143160
```{r}
@@ -150,7 +167,10 @@ b3data_package <- create_package() %>%
150167
"Occurrence cube for birds in Belgium between 2000 en 2024.",
151168
"The taxonomical resolution is 'species' and",
152169
"the temporal resolution is 'year'",
153-
"Spatial aggregation is done using the MGRS grid at 10 km scale."),
170+
"Spatial aggregation is done using the MGRS grid at 10 km scale.",
171+
"Only grid cells that fall within the 10 km MGRS reference grid for",
172+
"mainland Belgium (see b3data: `mgrs10_refgrid_belgium.geojson`) are",
173+
"included."),
154174
sources = c(
155175
title = "GBIF Occurrence Download",
156176
path = "https://doi.org/10.15468/dl.y3wpwk"

0 commit comments

Comments
 (0)