Skip to main content

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

Python License: MIT GitHub Coverage PyPI version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

popexposure-1.0.0.dev18.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

popexposure-1.0.0.dev18-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file popexposure-1.0.0.dev18.tar.gz.

File metadata

  • Download URL: popexposure-1.0.0.dev18.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

Hashes for popexposure-1.0.0.dev18.tar.gz
Algorithm Hash digest
SHA256 08d24ef348e540f45b867b015d2ae09c09275c6b9b1bb05f892f32d851e24d31
MD5 325bb3dd99c288085301edd78d624c8e
BLAKE2b-256 30d05fc0ad3bb6e17529839d25db8704147467e306f1c9084e96b48e719c1fe2

See more details on using hashes here.

File details

Details for the file popexposure-1.0.0.dev18-py3-none-any.whl.

File metadata

  • Download URL: popexposure-1.0.0.dev18-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

Hashes for popexposure-1.0.0.dev18-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f391bcbed5bc8006b91117fb793d743976f59a96d5c3ac8126d0af1a518e3d
MD5 a2b6408b056fcc22dd4a1c86c5c04801
BLAKE2b-256 757ce0c170203f12b292d0991acf08949313f734cd423effc6c486deb900a0b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page