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. The main
features extracted are:
amenity
building
craft
cycleway
emergency
highway
historic
landuse
leisure
man_made
military
natural
office
power
public_transport
railway
shop
sport
tourism
For more details on the features that are extracted, check FEATURES.md and the OSM wiki.
Example generated dataframe:
Data visualised on a map:
After cloning the project into your local machine, the first thing will be to create a virtual environment with the required packages. For this, it is highly recommended to use conda, as it will make sure all packages can be installed. Thus, run:
$ conda env create -f environment.yml
$ conda activate osm-feature-extractor
in order to run the app do:
$ python 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_data_file: Name of file containing GeoJSON polygon(s) to be map the features against.
out_file: Path to the output file where all features will be extracted 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.
`