Skip to content

Latest commit

 

History

History
233 lines (145 loc) · 6.96 KB

File metadata and controls

233 lines (145 loc) · 6.96 KB

Gaza spatial vulnerability

Quantifying and mapping population exposure to risks in Gaza

This repository contains an R workflow for staging source data, building a consolidated geodatabase, and calculating grid-based spatial vulnerability indicators for Gaza.

The workflow is driven by the working directory defined in .env. All source data used by the analysis should be available beneath wd/in, and all deliverables are written beneath wd/out.

Workflow overview

Run the components in this order:

  1. 00_stage_inputs.R stages the required source data into the local input tree.
  2. 10_geodatabase.R builds the consolidated source GeoPackage.
  3. 20_vulnerability_indicators.R calculates the vulnerability rasters from the source GeoPackage.
  4. 10_helpers.R provides shared functions used by the geodatabase and indicator scripts.

Repository layout

  • src/00_stage_inputs.R: stages and validates the curated input files
  • src/10_geodatabase.R: builds gaza_geodatabase.gpkg
  • src/10_helpers.R: shared utility functions
  • src/20_vulnerability_indicators.R: builds the spatial vulnerability outputs
  • required.R: installs required R packages
  • required.sh: installs required Linux system dependencies
  • example_env: example environment configuration
  • .env: local working-directory configuration; not committed
  • LICENSE: project license

Setup

Create a local .env file based on example_env and set:

wd='/path/to/project-working-directory'

The scripts expect the following directories to be created beneath wd:

  • wd/in: staged source inputs
  • wd/out/geodatabase: source geodatabase output
  • wd/out/spatial_vulnerability: vulnerability output

Install the R dependencies from required.R. On Linux, install the system dependencies listed in required.sh.

1. Stage inputs: 00_stage_inputs.R

This script creates a curated local input tree from the configured source data. It is intended to make the workflow reproducible and independent of mutable external source paths.

The staged input tree is organized by source, including:

  • Real Good Research GazaNowPop population rasters
  • Real Good Research GazaTents layers
  • UNOSAT damage, flood, storm-surge, and tent-mapping layers
  • UNOCHA administrative boundaries and exclusion zones
  • the NowPop mastergrid

The script should be run whenever source inputs change or the staged input directory needs to be refreshed.

Run it with:

source("src/00_stage_inputs.R")

2. Build the source geodatabase: 10_geodatabase.R

This script reads the staged files from wd/in and creates:

wd/out/geodatabase/gaza_geodatabase.gpkg

It starts from a clean output file and writes:

Reference layers

  • Gaza governorates
  • Gaza municipalities
  • Gaza neighbourhoods
  • UNOCHA exclusion zone / yellow line

UNOSAT layers

  • building damage
  • flood risk
  • storm surge
  • tent-mapping points

Real Good Research layers

  • GazaNowPop population rasters for all available dates
  • GazaTents point layers
  • GazaTents gridded layers

Metadata

The GeoPackage contains a data_catalogue layer describing each source layer, including its reference date, data type, source, sensitivity classification, classification scheme, and source URL.

Run it with:

source("src/10_geodatabase.R")

This script must be run before the vulnerability indicator script.

3. Shared helpers: 10_helpers.R

This file is sourced by the workflow scripts and is not normally run directly.

It provides:

  • sanitize_layer_name(): creates safe, lower-case layer names
  • make_source_url(): creates Real Good Research source URLs from collection dates
  • align_raster_to_template(): aligns rasters to the mastergrid CRS, extent, resolution, and geometry
  • write_gpkg_raster(): writes raster layers to GeoPackage format

The indicator workflow uses temporary raster and GeoPackage assembly steps when writing outputs because the source GeoPackage remains open while derived rasters are being created.

4. Calculate vulnerability indicators: 20_vulnerability_indicators.R

This script reads:

wd/out/geodatabase/gaza_geodatabase.gpkg

and writes:

wd/out/spatial_vulnerability/spatial_vulnerability.gpkg

The output is rebuilt from scratch each time the script runs.

Mastergrid and spatial rule

All outputs use the NowPop mastergrid. For flood-risk and storm-surge indicators, a grid cell is affected when any part of the cell touches a relevant UNOSAT polygon.

Affected cells receive the full population value. Unaffected cells receive zero.

Flood-risk and storm-surge population

The script calculates these indicators for four population dates:

  • 2026-03-01
  • 2026-03-24
  • 2026-05-04
  • 2026-06-09

Outputs are named:

  • floodrisk_population_YYYYMMDD
  • stormsurge_population_YYYYMMDD

Housing and tent inputs

The dwelling indicators use:

  • population: realgood_gazanowpop_20260301
  • tents: unosat_gaza_tent_points_20260300
  • damage: unosat_gaza_damage_20251011

Undamaged housing units are calculated as:

HU_tot - HU_damaged_14

Negative values are flagged with a warning and replaced with zero.

Each tent point represents one dwelling. Total dwellings are:

tents + undamaged housing units

People per dwelling and population allocation

People per dwelling is:

population / total dwellings

The script assumes equal household sizes across tents and undamaged housing units. It therefore calculates:

  • population_in_tents_20260301
  • population_in_housing_20260301

using the tent and housing shares of total dwellings.

The overall dwelling-density output is:

  • people_per_dwelling_20260301

Cells with zero dwellings are set to NA.

Output data catalogue

The vulnerability GeoPackage contains a data_catalogue layer with:

  • layer_name
  • reference_date
  • data_type
  • source
  • sensitivity_classification
  • classification_scheme
  • source_url
  • input_layers
  • notes

The input_layers field records the source population, exposure, tent, and damage layers used for each derived output. The notes field provides a short explanation of each output.

Archived proportion indicators

Earlier versions calculated the proportion of dwellings that were tents or undamaged housing units. That code remains commented out in the indicator script for reference and is not currently written to the output GeoPackage.

Re-running the workflow

To rebuild all outputs:

source("src/00_stage_inputs.R")
source("src/10_geodatabase.R")
source("src/20_vulnerability_indicators.R")

If source inputs have not changed, 00_stage_inputs.R may be skipped, but 10_geodatabase.R must be rerun before the indicator script whenever the source geodatabase needs refreshing.

Naming conventions

Dates use YYYYMMDD. Examples:

  • realgood_gazanowpop_20260301
  • unosat_gaza_damage_20251011
  • floodrisk_population_20260301
  • population_in_tents_20260301

License

Copyright (c) 2026 Real Good Research Ltd.

This project is licensed under the GNU General Public License v3.0. See LICENSE.