This release is a pre-release and may not be stable for production use.
popexposure: Functions to estimate the number of people living near environmental hazards
Overview
popexposure is an open-source Python package providing fast, memory-efficient, and consistent estimates of the number of people living near environmental hazards, enabling environmental scientists to assess population-level exposure to environmental hazards based on residential proximity. Methodological details can be found in McBrien et al (2025). Extensive documentation can be found on in our quick start tutorial.
Installation
The easiest way to install popexposure is via the latest pre-compiled binaries from PyPI with:
pip install popexposure
You can build popexposure from source as you would any other Python package with:
git clone https://github.com/heathermcb/popexposure
cd popexposure
python -m pip install .
Tutorials
A number of tutorials providing worked examples using popexposure can be found in our tutorials folder.
Quickstart
import glob
import pandas as pd
import popexposure as ex
# Set paths
my_pop_raster_path = "my_pop_raster.tif"
admin_units_path = "my_admin_units.geojson"
# Instantiate estimator
pop_est = ex.PopEstimator(pop_data = my_pop_raster_path, admin_data= my_admin_units.geojson)
# List of years and corresponding hazard file paths
years = [2016, 2017, 2018]
hazard_paths = [
"hazard_2016.geojson",
"hazard_2017.geojson",
"hazard_2018.geojson"
]
# Find total num ppl residing <= 10km of each hazard in each year
exposed_list = []
for year, hazard_path in zip(years, hazard_paths):
# Estimate exposed population
exposed = pop_est.est_exposed_pop(
hazard_specific=False, # set to True if you want per-hazard results
hazards=hazard_path,
)
exposed['year'] = year
exposed_list.append(exposed)
exposed_df = pd.concat(exposed_list, axis=0)
# Save output
exposed_df.to_parquet("pop_exposed_to_hazards.parquet")
Available methods
| Function | Overview | Inputs | Outputs |
|---|---|---|---|
PopEstimator |
Main class for estimating population exposure; initializes with population and optional admin data | pop_data (raster path), admin_data (GeoJSON or shapefile path) |
PopEstimator object |
est_exposed_pop |
Estimates number of people living within a specified distance of hazards | hazards (GeoJSON/shapefile), hazard_specific (bool) |
DataFrame with exposed population counts by hazard/admin unit |
est_total_pop |
Estimates total population in administrative units | None (uses data provided at initialization) | DataFrame with total population per administrative unit |
Getting help and contributing
If you have any questions, a feature request, or would like to report a bug, please open an issue. We also welcome any new contributions and ideas. If you want to add code, please submit a pull request and we will get back to you when we can. Thanks!
Citing this package
Please cite our paper McBrien et al (2025).
Authors
References
Our package is a fancy wrapper for the package exactextract.
Metadata
Release files for popexposure 1.0.0.dev18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| popexposure-1.0.0.dev18.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| popexposure-1.0.0.dev18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / popexposure-1.0.0.dev18.tar.gz
| Download URL | popexposure-1.0.0.dev18.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08d24ef348e540f45b867b015d2ae09c09275c6b9b1bb05f892f32d851e24d31
|
|
BLAKE2b-256 checksum How to use checksums |
30d05fc0ad3bb6e17529839d25db8704147467e306f1c9084e96b48e719c1fe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.12.6 Darwin/22.6.0
|
Release files / popexposure-1.0.0.dev18-py3-none-any.whl
| Download URL | popexposure-1.0.0.dev18-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2f391bcbed5bc8006b91117fb793d743976f59a96d5c3ac8126d0af1a518e3d
|
|
BLAKE2b-256 checksum How to use checksums |
757ce0c170203f12b292d0991acf08949313f734cd423effc6c486deb900a0b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.12.6 Darwin/22.6.0
|