SPARC Building Scan is a geospatial workflow that generates high-quality, analysis-ready building footprints for urban areas.
src/: Python source code to run the building scan.quarto_book/: Markdown and Quarto source files for the documentation pages.notebooks/: Exploratory notebooks for analysis and experimentation..github/workflows/: CI workflows to build a preview of pages and publish.
This project requires Python >=3.9. Use a virtual environment to manage dependencies. You can create and activate a virtual environment using the following commands:
python -m venv .venv # virtual env will use the default Python that runs this command; check with `python --version`
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`Then install the required dependencies:
cd src
pip install -r requirements.txtconda create -n sparc python=3.12
conda activate sparc
cd src
pip install -r requirements.txtuv is a fast Python package and environment manager. It downloads Python 3.12 automatically if it isn't already installed. Install uv with one of the following:
# macOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows:
winget install --id=astral-sh.uv -e
# pip (install outside of any conda environment)
pip install uvThen create the environment and install dependencies:
cd src
uv venv --python 3.12
uv pip install -r requirements.txtNote: If a conda environment is active (e.g.,
(base)in your prompt), runconda deactivatebefore using venv or uv. Otherwise, the conda environment may be used instead of.venv.
The workflow is run as a series of 4 Python scripts, which themselves are composed of smaller scripts that handle specific tasks (download, data prep, etc.). The only arguments that need to be passed are --city-name, --aoi (path to the city extent file, typically a GeoJSON), and --data-root (working directory where inputs and outputs are stored).
Activate the environment as above and run the scripts as follows:
If using Windows:
cd src
.venv\Scripts\activate
python 1_data_integration/run_workflow.py ^
--city-name "Juba" ^
--aoi C:/Users/USERNAME/tmp/sparc/data/SPARC_AOI_Juba.geojson ^
--data-root C:/Users/USERNAME/tmp/sparc/workflow/ ^
--skip-gba-heightNote: gba-height currently raises issues on the WB network.
From Mac/linux the commands are identical, but use \ for line continuation instead of ^:
cd src
source .venv/bin/activate
python 1_data_integration/run_workflow.py \
--city-name "Juba" \
--aoi ~/Documents/sparc/juba/SPARC_AOI_Juba.geojson \
--data-root ~/sparc/data/The documentation is built with Quarto. Installation is optional but helpful for previewing changes locally. You can install it on WB machines via the software center. For other systems, follow the installation instructions on the Quarto website.
-
Clone the repository:
git clone https://github.com/worldbank/SPARC_building_scan.git cd SPARC_building_scan -
Create a new branch:
git checkout -b my-new-branch
-
Edit the documentation pages inside
quarto_book/. -
Preview your changes locally (optional):
quarto preview
This opens a live preview in your browser that updates as you edit. To build the full site instead, run
quarto render, which writes the output todocs/. Git does not track this folder. -
Commit your changes:
git add . git commit -m "Description of changes"
-
Push your branch and open a pull request:
git push -u origin my-new-branch
Then go to the repository on GitHub and open a pull request from your branch into
main.
On every pull request, GitHub Actions will:
- Install dependencies.
- Render the Quarto project.
- Upload the rendered files as an artifact.
- Publish a preview to the
gh-pagesbranch underpr-preview/pr-<PR_NUMBER>/.
The preview will be available at https://worldbank.github.io/SPARC_building_scan/pr-preview/pr-<PR_NUMBER>/.
New commits to an open pull request rerun the workflow and update the preview.
On every push to main, GitHub Actions will:
- Install dependencies.
- Render the Quarto project.
- Upload the rendered files as an artifact.
- Publish the updated documentation to the
gh-pagesbranch.
The website is publicly available at https://worldbank.github.io/SPARC_building_scan/.