jcoupey / osmium-polygon

Create OSM extracts using custom polygons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

This project is the result of playing around with libosmium and polygon inclusion.

It allows to extract all nodes, ways and relations in an OSM data file with regard to inclusion in a set of (multi-)polygons defined in a simple geojson file.

  • Nodes included in the polygons are kept.
  • Ways containing at least a node in the polygons are kept and stay complete (even their nodes that are not in the polygons are included).
  • Relations that have at least one node or a way member in the polygons are included with all their members (not reference-complete).

Examples

Single polygon

Using this geojson file.

berlin heart

Polygon with a hole

Using this geojson file.

berlin ring

Several (multi-)polygons

Using this geojson file.

berlin flower

Build

Make sure boost is installed on your system, clone the repo and build from the src folder.

git clone https://github.com/jcoupey/osmium-polygon.git
cd osmium-polygon/src/
make
cd ..

Usage

Use -p to describe which geojson file contains your (multi-)polygons and run on any OSM data file.

./osmium-polygon -p files/berlin_heart.geojson berlin-latest.osm.pbf

Tests

In the src folder, build and run using:

make test
cd ../
./osmium-polygon-tests

About

Create OSM extracts using custom polygons

License:BSD 2-Clause "Simplified" License


Languages

Language:C++ 98.9%Language:C 1.0%Language:Makefile 0.0%