Skip to main content

Library to extract OSM features and map them to GeoJSON polygons.

Project description

OSM Feature Extractor

Introduction

Lightweight application to automatically extract features from an OSM file, and map them to user defined GeoJSON polygon(s). The mapped features can then be potentially used for machine learning applications based on OSM data. The extracted features can be a count for nodes, a length for ways and area for areas.

For more details on the features that are extracted, check FEATURES.md and the OSM wiki.

Example generated dataframe:

df

Data visualised on a map:

df

Usage

After cloning the project into your local machine, you'll need to create a virtual environment with the required packages. This can be achieved easily with Poetry, as it will make sure all the versions are correct, but alternatively it can be installed by other means with the requirements.txt file provided. At the root directory of the project run:

$ poetry install

$ poetry shell

When all the packages have been installed and the virtual env is activated, you can then run the script that will map the features:

$ python osm_feature_extractor/main.py

The above command will run on an included OSM file isle-of-wight-latest.osm.pbf and isle-of-wight.geojson.

You can go to configuration file in order to adjust the app configuration parameters. The main ones are detailed below:

osm_file: Name of osm file whose features will be extracted. To download more files visit the geofabrik website.
input_polygons_file: Name of file containing the GeoJSON polygon(s) for which the OSM features will be mapped against.
output_file: Path to the output file where the mapped OSM features are written to.

Note: Large files might take a while to process. It is recommended to use the CLI osmium extract tool in order to reduce the OSM file to the area of interest first and then run the feature extractor.

`

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_feature_extractor-0.1.4.tar.gz (15.9 MB view hashes)

Uploaded Source

Built Distribution

osm_feature_extractor-0.1.4-py3-none-any.whl (15.9 MB view hashes)

Uploaded Python 3

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