Python package for flexible data extraction from OpenStreetMap
Project description
osm-flex
Python package for flexible data extraction from OpenStreetMap. This packages allows to
- download OSM data dumps
- [optional] clip to desired shape
- extract specific features to geodataframes
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.
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')
gdf_ch_forest = ex.extract(
path_che_dump, 'multipolygons', ['landuse', 'name'], "landuse='forest'"
)
Running Tests
Follow installation instructions. Then,
python -m pip install -e "./[tests]"
pytest
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
osm-flex-1.0.1.tar.gz
(31.7 kB
view hashes)
Built Distribution
osm_flex-1.0.1-py3-none-any.whl
(30.8 kB
view hashes)