2

Tools like osmosis, osmfilter, or osmconvert allow just clipping data to a defined bounding box or a polygon (besides filtering by attributes).

What is the best way to delete all objects inside multiple defined areas? In other words: I want do do an erase operation on OSM data. Is there a simpler way than importing OSM data to a database, processing there and writing back to a file?

2
  • 1
    What program are you using, and what are you attempting to accomplish? Arc and Q both have Erase/Difference tools that could accomplish this.
    – jcarlson
    Commented Feb 7, 2018 at 17:27
  • 1
    The aim is to prepare OSM data for routing. Because it's not ordinary car routing, nearly all ways should be routable. Sole exception are ways inside military areas. Those ways unfortunately don't have an attribute like "military" in most cases, other attributes like "access=private" are not specific enough. Therefore I want to delete ways inside military areas using polygons which cover military areas as mask. I'm looking for a tool which can handle big OSM files (several GB) like the conversion tools mentioned above.
    – Mesa
    Commented Feb 7, 2018 at 19:43

1 Answer 1

3

You could use the approach outlined here: https://help.openstreetmap.org/questions/56269/how-to-cut-out-data-within-a-defined-polygon-with-osmosis

In your own poly file you use for filtering in osmconvert, osmium, etc, define a large polygon covering the whole area and substract each single military polygon by using an exclamation mark respectively. Check the Poly Filer File Format documentation for further details.

3
  • This solution works partially: it seems to delete only the nodes inside military areas and does not consider the course of the ways. So, when a road crosses a military area, only the vertices inside the area are deleted but the line is not cut and leads straight through the military area.
    – Mesa
    Commented Feb 12, 2018 at 15:57
  • Osmium has three extract strategies, but unfortunately none of them is "drop way when at least one node is outside the specified region"
    – Mesa
    Commented Feb 13, 2018 at 11:00
  • You could try and open a feature request on the project github page: github.com/osmcode/osmium-tool/issues
    – mmd
    Commented Feb 13, 2018 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.