What to build
A data-raw/ vignette (R script) run once by WB package maintainers whenever the WB Official Boundaries dataset is updated. It downloads the source GeoJSONs/shapefiles, converts them to three global parquet files (one per admin level), and a per-country hex-grid parquet at H3 resolution 6. These files are then uploaded to the WB Data Catalog as dataset resources and become the backing store for get_country_shapes() (Inf-4).
This is not end-user code. It runs in a controlled WB environment with write access to the Data Catalog.
Output parquet files
Three boundary parquets (one per admin level, all countries in one file):
wb_boundaries_admin0.parquet
wb_boundaries_admin1.parquet
wb_boundaries_admin2.parquet
Schema per file:
| Column |
Type |
Notes |
iso3 |
string |
ISO-3 country code — primary filter key |
admin_level |
int |
0, 1, or 2 |
pcod |
string |
Unique polygon code (maps to admin<N>Pcod in the package) |
name |
string |
English polygon name (maps to admin<N>Name) |
name_local |
string |
Local-language name (null if unavailable) |
parent_pcod |
string |
Parent-level pcod; null for admin0 |
area_km2 |
double |
Pre-computed area in km² |
geometry |
binary |
WKB (Well-Known Binary) polygon geometry |
wb_source_version |
string |
WB Boundaries dataset version tag |
Geometry stored as raw WKB binary column (compact; readable with sf::st_as_sfc()). Arrow predicate pushdown on iso3 means get_country_shapes("RWA") reads only Rwanda rows from each file.
One hex-grid parquet per country (pre-computed H3 resolution 6 grid + spatial join to admin boundaries):
wb_hex_r6_{iso3}.parquet or partitioned as wb_hex_r6/iso3={iso3}/data.parquet
Schema:
| Column |
Type |
Notes |
admin9Pcod |
string |
H3 cell ID at resolution 6 |
admin0Pcod |
string |
Parent country code |
admin1Pcod |
string |
Parent admin1 pcod |
admin2Pcod |
string |
Parent admin2 pcod (null if country has no admin2) |
area_km2 |
double |
Cell area |
resolution |
int |
Always 6 in v1 |
geometry |
binary |
WKB hex polygon |
ETL steps (within the vignette)
- Download each admin-level GeoJSON/shapefile from WB Official Boundaries
- Standardise column names to the schema above; compute
area_km2; derive parent_pcod via spatial join of centroids where not already present in source
- Convert geometry to WKB binary:
sf::st_as_binary(geometry)
- Write to parquet using
arrow::write_parquet() — one file per admin level
- For each country: build H3 resolution-6 hex grid via
make_hex_grid() + make_admin_lookup() and write hex parquet
- Upload all files to WB Data Catalog as dataset resources; record the base URL
Dependencies
New package dependencies for this ETL script (not for end users — Suggests or script-only):
arrow (already in pipeline for hex fetch)
sf
h3jsr (already used for hex grid)
Acceptance criteria
Blocked by
None — can start immediately.
What to build
A
data-raw/vignette (R script) run once by WB package maintainers whenever the WB Official Boundaries dataset is updated. It downloads the source GeoJSONs/shapefiles, converts them to three global parquet files (one per admin level), and a per-country hex-grid parquet at H3 resolution 6. These files are then uploaded to the WB Data Catalog as dataset resources and become the backing store forget_country_shapes()(Inf-4).This is not end-user code. It runs in a controlled WB environment with write access to the Data Catalog.
Output parquet files
Three boundary parquets (one per admin level, all countries in one file):
wb_boundaries_admin0.parquetwb_boundaries_admin1.parquetwb_boundaries_admin2.parquetSchema per file:
iso3admin_levelpcodadmin<N>Pcodin the package)nameadmin<N>Name)name_localparent_pcodarea_km2geometrywb_source_versionGeometry stored as raw WKB binary column (compact; readable with
sf::st_as_sfc()). Arrow predicate pushdown oniso3meansget_country_shapes("RWA")reads only Rwanda rows from each file.One hex-grid parquet per country (pre-computed H3 resolution 6 grid + spatial join to admin boundaries):
wb_hex_r6_{iso3}.parquetor partitioned aswb_hex_r6/iso3={iso3}/data.parquetSchema:
admin9Pcodadmin0Pcodadmin1Pcodadmin2Pcodarea_km2resolutiongeometryETL steps (within the vignette)
area_km2; deriveparent_pcodvia spatial join of centroids where not already present in sourcesf::st_as_binary(geometry)arrow::write_parquet()— one file per admin levelmake_hex_grid()+make_admin_lookup()and write hex parquetDependencies
New package dependencies for this ETL script (not for end users —
Suggestsor script-only):arrow(already in pipeline for hex fetch)sfh3jsr(already used for hex grid)Acceptance criteria
data-raw/etl-wb-boundaries.Rscript exists and is runnable by a WB maintainer with Data Catalog write accessarrow::open_dataset()+dplyr::filter(iso3 == "RWA")sf::st_as_sfc()recovers valid polygonswb_source_versioncolumnREADMEnote indata-raw/explains when and how to re-run this scriptBlocked by
None — can start immediately.