Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diogomatoschaves/osm-feature-extractor
A lightweight CLI to extract features from an OSM file and map them to GeoJSON polygons.
https://github.com/diogomatoschaves/osm-feature-extractor
feature-augmentation feature-engineering feature-extraction openstreetmap osm python
Last synced: 3 months ago
JSON representation
A lightweight CLI to extract features from an OSM file and map them to GeoJSON polygons.
- Host: GitHub
- URL: https://github.com/diogomatoschaves/osm-feature-extractor
- Owner: diogomatoschaves
- Created: 2020-04-20T12:01:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T06:57:03.000Z (4 months ago)
- Last Synced: 2024-10-01T14:59:28.434Z (3 months ago)
- Topics: feature-augmentation, feature-engineering, feature-extraction, openstreetmap, osm, python
- Language: Python
- Homepage:
- Size: 65.5 MB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OSM Feature Extractor
[![PyPI version](https://badge.fury.io/py/osm-feature-extractor.svg)](https://badge.fury.io/py/osm-feature-extractor)
A lightweight command line interface designed to extract features from an OpenStreetMap (OSM)
file and map them to user-defined areas (polygons) contained in a GeoJSON file.
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](FEATURES.md) and
the [OSM wiki](https://wiki.openstreetmap.org/wiki/Map_Features).Example generated dataframe:
![df](osm_feature_extractor/utils/img/data_frame.png)
Data visualised on a map:
![df](osm_feature_extractor/utils/img/data_kepler.png)
## 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 \
--input-polygons-file \
--output-fileTo 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
The configuration file should have the following format:
```shell
[user-defined]
osm_file:
input_polygons_file:
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](https://docs.osmcode.org/osmium/latest/osmium-extract.html)
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