Skip to main content

osm-flex

Logo

github repo badge github license badge PyPI version PyPI - Downloads Documentation Status fair-software.eu DOI

Python package for flexible data extraction from OpenStreetMap. This packages allows to

  1. download OSM data dumps
  2. [optional] clip to desired shape
  3. extract specific features to geodataframes
  4. [optional] simplify results based on geospatial operations

Documentation

Please refer to the ReadTheDocs of this project for the full documentation of all functions.

Installation

conda create -n osm-flex cartopy geopandas
conda activate osm-flex
pip install osm-flex

NOTE

This package requires shapely v2.0 or later. Installing this package in an existing environment might overwrite older versions.

The (optional) clipping functionalities require manual installation of osmconvert or osmosis. See tutorial 1 for details.


Example

Download osm data for Switzerland from geofabrik.

import osm_flex.download as dl

iso3 = 'CHE'
dl.get_country_geofabrik(iso3)

Extract all buildings related to education and extract all polygons with forests.

import osm_flex.extract as ex
from osm_flex.config import OSM_DATA_DIR

path_che_dump = OSM_DATA_DIR.joinpath('switzerland-latest.osm.pbf')              
gdf_ch_education = ex.extract_cis(path_che_dump, 'education')    
Education GeodataFrame
gdf_ch_forest = ex.extract(
	path_che_dump, 'multipolygons', ['landuse', 'name'], "landuse='forest'"
	)    
Forest map

Drop all education building units that are contained within larger education buildings.

import osm_flex.simplify as sy
gdf_ch_education = sy.rremove_contained_polys(gdf_ch_education)

Running Tests

Follow installation instructions. Then,

python -m pip install -e "./[tests]"
pytest

Metadata

Release files for osm-flex 1.1.1

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

Source distribution (sdist)

Source distribution for osm-flex 1.1.1
File Size Uploaded Provenance Actions
osm-flex-1.1.1.tar.gz 34.0 kB Without provenance Details for osm-flex-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for osm-flex 1.1.1
File Interpreter ABI Platform Actions
osm_flex-1.1.1-py3-none-any.whl Python 3 none any Details for osm_flex-1.1.1-py3-none-any.whl

Total release size: 67.0 kB

Release files / osm-flex-1.1.1.tar.gz

Download URL osm-flex-1.1.1.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5a45e28bc8280eb4dcaf7d776efa3792bc46583ab8ade2d70609dad3894111fd
BLAKE2b-256 checksum
How to use checksums
debfbe722c4e237bb01a20f7afd524a8fb4bd57719dd0a46a8bca919ac4750df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / osm_flex-1.1.1-py3-none-any.whl

Download URL osm_flex-1.1.1-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e369e32120ab852e25f98b09245f342823855100a9cda6763f37c751542bfecb
BLAKE2b-256 checksum
How to use checksums
0e64a07ccca8fb1ef8cced5861961dd23356b3a4ca64643cab0f57bec493e4eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Security for osm-flex 1.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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