Skip to main content

Python tool to extract large-amounts of OpenStreetMap data

Project description

earth-osm

by

PyPI version CI Size License: MIT Discord

earth-osm is a free software tool that can extract large-amounts of OpenStreetMap data. It implements filters and multi-processing for fast and memory-efficient computations. You can extract e.g. power lines for the whole Africa on your laptop. It builds on esy-osmfilter and improves its package design, usability and performance.

Getting Started

Install earth-osm

pip install git+https://github.com/pypsa-meets-earth/earth-osm.git

Extract osm data

# Example CLI command
earth_osm extract power --regions benin monaco  --features substation line

This will extract primary feature = power for the regions = benin and monaco and the secondary features = substation and line. By default the resulting .csv and .geojson are stored in ./earth_data/out

Load the substation data for benin using pandas

# 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')

Other Arguments

usage: earth_osm extract primary --regions region1, region2 --features feature1, feature2 --data_dir DATA_DIR [--update] [--mp]

primary (e.g power, water, road, etc) NOTE: currently only power is supported

--regions region1 region2 ... (use either iso3166-1:alpha2 or iso3166-2 codes or full names as given by running 'earth_osm view regions')

--features feature1 feature2 ... (optional, use sub-features of primary feature, e.g. substation, line, etc)

--update (optional, update existing data, dafult False)

--mp (optional, use multiprocessing, default True)

--data_dir (optional, path to data directory, default './earth_data')

Advanced Usage

import earth_osm as eo

eo.get_osm_data(
  primary_name = 'power',
  region_list = ['benin', 'monaco'],
  feature_list = ['substation', 'line'],
  update = False,
  mp = True,
  data_dir = './earth_data',
)

Development

(Optional) Intstall a specific version of earth_osm

pip install git+https://github.com/pypsa-meets-earth/earth-osm.git@<required-commit-hash>

(Optional) Create a virtual environment for python>=3.10

python3 -m venv .venv
source .venv/bin/activate

Read the CONTRIBUTING.md file.

pip install git+https://github.com/pypsa-meets-earth/earth-osm.git
pip install -r requirements-test.txt 

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

earth_osm-0.0.4.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

earth_osm-0.0.4-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file earth_osm-0.0.4.tar.gz.

File metadata

  • Download URL: earth_osm-0.0.4.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for earth_osm-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9f0e5e5618bf03f7c9bee26ac44a00da826bb9eeb0ce68f3dcaabc0a5a71c642
MD5 203315476b8c06b28f3eadf11455923f
BLAKE2b-256 2dd0653d0d0a161222f7954082deb94a88d10e60b65be8810957b70446997550

See more details on using hashes here.

File details

Details for the file earth_osm-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: earth_osm-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for earth_osm-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e5421b86237e0b9792c0c44452d1c0baa5b08a3e6c37c2edfe8dd19fee4bf5df
MD5 1c210b44c0cd6a75b7754b5a764a0958
BLAKE2b-256 663a53b78c0c84079974cadbba42bf6d49875550d2da75a8b5b75afd67bad997

See more details on using hashes here.

Supported by

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