@@ -22,6 +22,9 @@ library(tidyverse) # Data wrangling and visualisation
2222library(frictionless) # Create frictionless data package
2323library(sf) # Spatial objects
2424
25+ # Source functions
26+ source(here::here("source", "R", "add_manual_resource.R"))
27+
2528# Data path and create directory if necessary
2629data_path <- here::here("data", "raw")
2730dir.create(data_path, showWarnings = FALSE, recursive = TRUE)
@@ -89,38 +92,36 @@ Write to data package and add metadata.
8992``` {r}
9093st_write(mgrs10_refgrid_belgium,
9194 file.path(package_path, "mgrs10_refgrid_belgium.geojson"),
92- append = FALSE )
95+ delete_dsn = TRUE )
9396```
9497
9598``` {r}
96- if (FALSE) {
97- # Read package
98- b3data_package <- read_package(file.path(package_path, "datapackage.json"))
99-
100- # Add spatial resources manually
101- b3data_package$resources <- append(b3data_package$resources, list(
102- list(
103- name = "mgrs10_refgrid_belgium",
104- path = "mgrs10_refgrid_belgium.geojson",
105- profile = "spatial-data-resource",
106- format = "geojson",
107- title = "MGRS 10 Km reference grid Belgium",
108- description = "MGRS 10 Km reference grid for the mainland of Belgium.",
109- licenses = c(
110- name = "CC0 1.0",
111- path = "https://creativecommons.org/publicdomain/zero/1.0/",
112- title = "Creative Commons Zero v1.0 Universal"
113- )
114- )
115- ))
116-
117- # Write package to directory
118- # Write package to directory
119- write_package(
120- package = b3data_package,
121- directory = package_path,
122- compress = TRUE)
123- }
99+ # Read package
100+ b3data_package <- read_package(file.path(package_path, "datapackage.json"))
101+
102+ # Add resource to data package
103+ mgrs10_resource <- list(
104+ name = "mgrs10_refgrid_belgium",
105+ path = "mgrs10_refgrid_belgium.geojson",
106+ profile = "spatial-data-resource",
107+ format = "geojson",
108+ title = "MGRS 10 Km reference grid Belgium",
109+ description = "MGRS 10 Km reference grid for the mainland of Belgium.",
110+ licenses = c(
111+ name = "CC0 1.0",
112+ path = "https://creativecommons.org/publicdomain/zero/1.0/",
113+ title = "Creative Commons Zero v1.0 Universal"
114+ )
115+ )
116+
117+ b3data_package <- add_manual_resource(
118+ b3data_package, mgrs10_resource, replace = TRUE)
119+
120+ # Write package to directory
121+ write_package(
122+ package = b3data_package,
123+ directory = package_path,
124+ compress = TRUE)
124125```
125126
126127## EEA 100 km reference grid Europe
0 commit comments