A package for finding the number of people residing near environmental hazards
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file popexposure-1.0.0.dev17.tar.gz.
File metadata
- Download URL: popexposure-1.0.0.dev17.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.6 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0acdc229f20be5a9b8972c9a28450f8fe6a2c9fde8a7844b0323f33b64e04631
|
|
| MD5 |
57f5a38752ff65a538fc1b2e9fc4e5be
|
|
| BLAKE2b-256 |
2194b341bd14fdc3e5359624e51de67c8937a33853fcbc4380196c895095d2a3
|
File details
Details for the file popexposure-1.0.0.dev17-py3-none-any.whl.
File metadata
- Download URL: popexposure-1.0.0.dev17-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.6 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc59a80055e0981250ec04814368faf53d2ef0c814a86d60d4d00873f2114444
|
|
| MD5 |
2abfdf355621c5c9ddfeb87c25218e49
|
|
| BLAKE2b-256 |
e377358ab6188a7b2bf636eb3eec1613a53c4440b4c87e8d5503b4882af33205
|