This repository includes R scripts to produce subnational boundary data files corresponding with representative subnational survey data.
The boundary data can be used to map the Global Subnational Atlas of Poverty (GSAP), the Subnational Poverty and Inequality Database (SPID), and for estimating the population at high risk from climate-related hazards WBG scorecard vision indicator.
The code completes the following tasks:
- Prepares the admin-0 boundary data so that it corresponds with World Bank country codes and has unique geo_codes.
- Prepares subnational boundary data files.
- Collates and modifies raw boundary data so that it matches subnational samples in the SPID master list.
- Edge-matches subnational boundaries to admin-0 boundaries. Ensures that they form a valid planar partition, made of valid polygons and having no gaps or overlaps.
World Bank Official Boundaries are used to map admin-0 and disputed areas. Data files are available from the Development Data Hub.
Subnational boundary data sources include Global Administrative Unit Layers (GAUL) 2015, Nomenclature of Territorial Units for Statistics (NUTS), GADM (v4.1), United Nations Common Operational Datasets, and National Statistical Offices (NSOs).
The SPID master list maps each subnational household survey sample to regions mapped by the boundary data sources. This excel file provides the code with specific instructions to match and modify raw boundary data so that it corresponds with the geographic identifiers in household surveys.
To run the code and produce master spatial data files:
- Clone the repository
- Obtain the raw spatial data files and place them in the specified folders
- Prepare the SPID boundary master list excel file
- Run
00.MASTER.R
1- modify line 7 with the
/data
directory you are using (with raw spatial data) - modify line 11 with file path to the the SPID boundary master
- modify line 14 with the vintage (e.g., "AM24")
- modify line 7 with the
00_MASTER.R
sets directories, installs packages and runs all scripts01_admin0.R
prepares admin-0 boundaries02_subnat_prep.R
prepares non-standard subnational boundary data03_subnat.R
combines subnational boundary data based on SPID master list:- prepare source boundary data
- get unmodified boundaries
- construct modified boundaries
- look-up missing subnational boundaries
- clip subnational boundaries to admin-0 polygons
04_edgematch.R
edge-matches subnational boundaries to admin-0 polygons
Footnotes
-
The R package renv is used to install the same version of packages and dependencies. In case this fails, deactivate renv
renv::deactivate()
and try to run the master R script withoutrenv::restore
after installing the following packages (and their dependencies) from CRAN: sf, smoothr, lwgeom, dplyr, openxlsx. ↩