Skip to main content

earth-osm

One-command to extract infrastructure data from OpenStreetMap

📚 Overview

earth-osm downloads, filters, cleans and exports infrastructure data from OpenStreetMap (OSM). It provides a Python API and a CLI interface to extract data for various infrastructure types, such as power lines, substations, and more.

🌟 Key Features

  • 🔌 Extracts infrastructure data from OSM
  • 📅 Historical data support (specify target dates)
  • 🧹 Cleans and standardizes the data (coming soon)
  • 🚀 No API rate limits (data served from GeoFabrik)
  • 🐍 Provides a Python API
  • 🖥️ Supports multiprocessing for faster extraction
  • 📊 Outputs data in .csv and .geojson formats
  • 🌍 Supports planetary data extraction
  • 🖱️ Easy-to-use CLI interface
  • 🌐 Dual data sources: GeoFabrik (default) and live Overpass API

🚀 Getting Started

Installation

Install earth-osm using pip (recommended):

pip install earth-osm

Or with conda:

conda install --channel=conda-forge earth-osm

Basic Usage

Extract OSM data using the CLI:

earth_osm extract power --regions benin monaco --features substation line

This command extracts power infrastructure data for Benin and Monaco, focusing on substations and power lines. By default, the resulting .csv and .geojson files are stored in ./earth_data/out.

Load the extracted data using pandas:

import pandas as pd
import geopandas as gpd

# For Pandas
df_substations = pd.read_csv('./earth_data/out/BJ_raw_substations.csv')

# For GeoPandas
gdf_substations = gpd.read_file('./earth_data/out/BJ_raw_substations.geojson')

Optional: Speed up downloads with aria2c

Install aria2c (for example brew install aria2, sudo apt-get install aria2, or choco install aria2) and set EO_PARALLEL_DOWNLOADS greater than 1; earth-osm will then use multiple connections for .osm.pbf downloads and otherwise falls back automatically.

export EO_PARALLEL_DOWNLOADS=8    # fish: set -x EO_PARALLEL_DOWNLOADS 8
earth_osm extract power --regions germany --features line

🛠️ CLI Reference

Extract Command

earth_osm extract <primary> --regions <region1> <region2> ... [options]

Arguments:

  • <primary>: Primary feature to extract (e.g power)

Required Options:

  • --regions: Specify one or more regions using ISO 3166-1 alpha-2, ISO 3166-2 codes, or full names

Tip: A list of regions is available at regions.md

Optional Arguments:

Argument Description Default
--features Specify sub-features of the primary feature All features
--update Update existing data False
--mp [N] Enable multiprocessing, optionally capped at N processes Auto (all CPUs but one)
--no_mp Disable multiprocessing False (MP enabled)
--data_dir Path to data directory './earth_data'
--out_dir Path to output directory Same as data_dir
--out_format Export format(s): csv and/or geojson ['csv', 'geojson']
--agg_feature Aggregate outputs by feature False
--agg_region Aggregate outputs by region False
--source Data source: geofabrik (default) or overpass geofabrik

ℹ️ When using the Overpass backend, wildcard feature selections such as ALL_power are not supported. Specify concrete feature values instead, or switch to the Geofabrik source for wildcard exports.

Overpass request settings can be overridden with environment variables:

Environment variable Description Default
EO_OVERPASS_ENDPOINT Overpass API interpreter endpoint https://overpass-api.de/api/interpreter
EO_OVERPASS_REQUEST_TIMEOUT HTTP request timeout in seconds 600
EO_OVERPASS_QUERY_TIMEOUT Overpass query timeout in seconds 300

Planet-wide extractions

Use the special earth region to export the full OpenStreetMap planet snapshot.

earth_osm extract power --regions earth --features line 

🐍 Python API

For more advanced usage, you can use the Python API:

import earth_osm as eo

eo.save_osm_data(
    primary_name='power',
    region_list=['benin', 'monaco'],
    feature_list=['substation', 'line'],
    update=False,
    mp=True,
    data_dir='./earth_data',
    out_format=['csv', 'geojson'],
    out_aggregate=True,
    data_source='geofabrik'  # or 'overpass'
)

For historical data, add the target_date parameter:

from datetime import datetime

# Download historical data for a specific date
eo.get_osm_data(
    region_str='malta',
    primary_name='power',
    feature_name='line',
    target_date=datetime(2020, 1, 1)  # Jan 1, 2020
)

🛠️ Development

To contribute to earth-osm, follow these steps:

  1. (Optional) Install a specific version of earth_osm:

    pip install git+https://github.com/pypsa-meets-earth/earth-osm.git@<required-commit-hash>
    
  2. (Optional) Create a virtual environment for Python >=3.10:

    python3 -m venv .venv
    source .venv/bin/activate
    
  3. Install the development dependencies:

    pip install git+https://github.com/pypsa-meets-earth/earth-osm.git
    pip install -e .[dev]
    
  4. Read the CONTRIBUTING.md file for more detailed information on how to contribute to the project.

🤝 Community

Join our Discord community to connect with other users and contributors, ask questions, and get support.

📚 Documentation

For more detailed information, check out our full documentation.


Made with ❤️ by the PyPSA meets Earth team

earth-osm logo

Metadata

Release files for earth-osm 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for earth-osm 3.1.0
File Size Uploaded Provenance
earth_osm-3.1.0.tar.gz 185.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for earth-osm 3.1.0
File Interpreter ABI Platform
earth_osm-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 367.7 kB

Release files / earth_osm-3.1.0.tar.gz

Download URL earth_osm-3.1.0.tar.gz
Size 185.3 kB
Tags Source
SHA-256 checksum
How to use checksums
599cc972448a6aa494470c25b41dc60c107ea2383e03ee7991c358b4cf2c8c35
BLAKE2b-256 checksum
How to use checksums
57371fab8f45f35089b224508852c51f996db4968987b6cafa79199a60b83f64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / earth_osm-3.1.0-py3-none-any.whl

Download URL earth_osm-3.1.0-py3-none-any.whl
Size 182.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e12ee3a38635438b03f25c8a937d5dc9cb6a359b956a0aad9d9363218d6fff23
BLAKE2b-256 checksum
How to use checksums
9e00289c03d5da579ca5a170295b33ae9f3fdc499b275d6d35498f8c44df4a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for earth-osm 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for earth_osm-3.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page