Skip to main content

A library for calculating accessibility and equity metrics using OpenStreetMap data.

Project description

OSMSatLab

OSMSatLab is a Python library for comprehensive urban accessibility and equity analysis. It seamlessly integrates OpenStreetMap (OSM) service locations with WorldPop raster population data to calculate high-resolution coverage metrics.

Designed for ease of use, it automates data retrieval, processing, and visualization through a single unified interface.

Key Features

  • Automated Data Retrieval: Automatically identifies countries, downloads WorldPop geotiffs, and fetches cached OSM data for any given area.
  • Multi-Modal Analysis: Calculates distances using Euclidean, Driving (approximate), and Walking network metrics.
  • Coverage & Equity: Computes:
    • Coverage Ratio: Percent of population within a specific service threshold (e.g., 1km).
    • Service Density: Services per 1,000 inhabitants.
    • Service Burden: Population per service.
  • Integrated Visualization: Built-in plotting tools for population choropleths, service density maps, and distance histograms.
  • Efficient Architecture: Uses spatial indexing (KD-trees) and raster-vector hybridization for high-performance analysis on large regions.

Installation

You can install osmsatlab using pip or Poetry.

Using Poetry (Recommended)

poetry add osmsatlab

Using pip

pip install osmsatlab

Quick Start

The core of the library is the OSMSatLab facade class. It handles initialization and data loading automatically.

1. Basic Initialization

Initialize with a bounding box (minx, miny, maxx, maxy). This automatically downloads population data and OSM services.

from osmsatlab.core import OSMSatLab

# Bounding box for Amsterdam
bbox = (4.85, 52.33, 4.95, 52.40) 

# Initialize lab (downloads data automatically)
lab = OSMSatLab(bbox=bbox, crs="EPSG:3857")

2. Calculate Metrics

Compute accessibility metrics for a specific service category (e.g., 'healthcare', 'education_school').

# Calculate Accessibility (Euclidean, 1km threshold)
access_metrics = lab.calculate_accessibility_metrics('healthcare', threshold=1000, metric_type='euclidean')
print(f"Coverage Ratio: {access_metrics['coverage_stats']['coverage_ratio']:.2%}")

# Calculate Per-Capita Equity
equity_metrics = lab.calculate_per_capita_metrics('healthcare')
print(f"Services per 1k people: {equity_metrics['services_per_1000']:.4f}")

3. Visualization

Use the built-in visualization tools to generate maps instantly.

from osmsatlab.viz import render_maps
import matplotlib.pyplot as plt

# Generate maps for healthcare access
render_maps(lab, "Amsterdam", service_category='healthcare')
plt.show()

Project Structure

The library is organized into modular components:

  • osmsatlab.core: Contains the OSMSatLab facade class, the main entry point.
  • osmsatlab.io: Data fetching modules for OSM (osm.py) and WorldPop (population.py).
  • osmsatlab.metrics: Calculation logic for accessibility and per_capita metrics.
  • osmsatlab.spatial: Spatial operations and index (KDTree) management.
  • osmsatlab.viz: Visualization workflows, including render_maps and choropleth utilities.

Methodology

OSMSatLab uses a raster-based population approach combined with vector-based service locations.

  1. Population: WorldPop 100m/1km resolution rasters are masked to the Area of Interest (AOI).
  2. Services: OSM Points of Interest (POIs) are fetched and spatially indexed.
  3. Analysis: For every population pixel centroid, the nearest service distance is calculated. The population count of pixels falling within the distance threshold is aggregated to determine total coverage.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

osmsatlab-1.0.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

osmsatlab-1.0.1-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file osmsatlab-1.0.1.tar.gz.

File metadata

  • Download URL: osmsatlab-1.0.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Windows/11

File hashes

Hashes for osmsatlab-1.0.1.tar.gz
Algorithm Hash digest
SHA256 90c1c1ebe824fdc47b3eafebdfa4aac4a97a45e0e02217fc03cbffed2d0bf50c
MD5 975bd08b4b52e734061c4de23272822f
BLAKE2b-256 452ac9948be170db8afa3d84efaaba62c6dbfcc181fb4f428b13240018e954f2

See more details on using hashes here.

File details

Details for the file osmsatlab-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: osmsatlab-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Windows/11

File hashes

Hashes for osmsatlab-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8552efa91fbdafd6a9096934dc6a5dd3ce53dabcf87af86d9cf7bc1c599d60b
MD5 44ae9d46aad994f20973e02f882cf27e
BLAKE2b-256 e600dc214f0dafe957668b20ceabef2abe535873b8e09179ff707185826fbe24

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