Skip to main content

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

Project description

OSM Feature Extractor

PyPI version

A lightweight application designed to automatically extract features from an OpenStreetMap (OSM) file and map them to a user-defined GeoJSON file containing a collection of polygons. The extracted features can include count for nodes, length for ways, and area for areas. These features can then be used for machine learning applications based on OSM data.

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

Installation

$ pip install osm-feature-extractor

Usage

After installation, you can use the tool directly with the osm_feature_extractor command, which supports two primary operations: extract and analyze.

extract

The extract command requires a minimum of three flags:

$ osm_feature_extractor extract \
    --osm-file <path_to_osm_file> \ 
    --input-polygons-file <path_to_polygons_file> \
    --output-file <path_to_output_file>

To see all available flags, use the help command:

$ osm_feature_extractor extract --help

Alternatively, you can provide a .conf file with the required parameters:

$ osm_feature_extractor extract --conf-file <path_to_conf_file>

The configuration file should have the following format:

[user-defined]
osm_file: <path_to_osm_file>
input_polygons_file: <path_to_polygons_file>
output_file: <path_to_output_file>

[default]
process_base_data: True
process_osm_data: True
polygons_file: polygons.geojson
osm_extractor_files_dir: osm_extractor_files_dir

Note: Processing large OSM files may take some time. It is recommended to use the CLI tool osmium extract to reduce the OSM file to your area of interest before running the feature extractor.

analyze

The analyze command provides a quick overview of the OSM file, including the total number of nodes, ways, bounds, and the centroid. To use this feature, run:

 $ osm_feature_extractor analyze --osm-file <path_to_osm_file>

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

Uploaded Source

Built Distribution

osm_feature_extractor-0.2.1-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