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.0.tar.gz (18.3 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.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osmsatlab-1.0.0.tar.gz
  • Upload date:
  • Size: 18.3 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.0.tar.gz
Algorithm Hash digest
SHA256 66fcac56a706859bea64855c4a5ad9e04d7e76351a620b539a7455c18f2dd943
MD5 d7132e968b18f71d8a6349e9297cf813
BLAKE2b-256 17685a7fcc78dd8b5b12317a290af5c9a0bb4002109cced9119fa9ae1455899b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: osmsatlab-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8bd2dd5f7853bfaf0ad06ecd180b6838255653f9fee1ca7a8874bb928053485
MD5 6e91e8e720ebae37a3cff9ca734316c8
BLAKE2b-256 253dc73e1d8496a52e250628e4a09b0b391e904b21c0af6f380f58934078e95f

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