I have a OSM file (http://download.geofabrik.de/europe/malta-latest.osm.pbf). I am only interested in data that are around ramps (motorway_link,trunk_link,primary_link,secondary_link,tertiary_link) as in the picture. Therefore I want to preprocess the data to keep the OSM file as small as possible. I use the osmium tool.
I want to do it as followed, but I do not know how to implement step 2:
- Filter pbf file by desired tags -> malta-ramps.osm.pbf
osmium tags-filter -v --overwrite -o malta-ramps.osm.pbf malta-latest.osm.pbf w/highway=motorway_link,trunk_link,primary_link,secondary_link,tertiary_link
- Create polygons around the filteres data -> malta-polygons.poly
How to create the buffered polygons around the ramps e.g. with python?
- Cut out the polygons from the original OSM file -> malta-finished.osm.pbf
osmium extract --overwrite -p malta-polygons.poly -o malta-finished.osm.pbf malta-latest.osm.pbf
ogr2ogr -f GeoJSON lines.geojson malta-ramps.osm.pbf lines
- compute a bufferogr2ogr -f GeoJSON buffer.geojson lines.gpkg -dialect sqlite -sql "select st_buffer(geom, 0.0001) from lines"
NOTE the buffer distance is in degrees, which is quite hacky. To use metric distance you need to transform to a metric CRS like UTM. Then you might union the buffered polygons to prevent overlap. Finally convert the polygons to a format osmium understand as describe here osmcode.org/osmium-tool/…