Search code examples
algorithmgeometryopenstreetmappath-finding

OpenStreetMap: Get all entrances in a park


I've extracted some National Parks from Openstreetmap. But now I want to find out where the entrances are. Openstreetmap has some tags for it but it isn't used that often.

So I tought: An entrance into a national park is a road which crosses the border of that park. Must be true: You are going into the park. The only downside I can think off is that it could be a private road for staff or something but that should be a small percentage.

enter image description here

So what is the best ways to find these points?

My guess: I know the boundaries of the park. So I can download all roads in that park. Then I can use the "Ray casting algorithm" for all sections of all roads in the parks to see if it crosses a border. When it does: that is a road that goes into the park. However, that might be very slow. If you have a large park with lots of roads inside it, it might take ages to check all segments.
Is there a more clever way?


Solution

  • You could use overpass turbo for this task: the following solution will identify all ways, which intersect with the boundary of a national park relation.

    Try it in overpass turbo! http://overpass-turbo.eu/s/aSN

    Just navigate to the area you're interested in and hit "Run".

    Here's a brief explanation how this query works:

    // restrict search to current bounding box
    [bbox:{{bbox}}];          
    // get all relations with tag boundary = national_park             
    rel[boundary=national_park];           
    // get all ways in this relation and store it in inputset boundaryways
    way(r)->.boundaryways;
    // now get all highway ways, which intersect our ways in boundaryways 
    way[highway](around.boundaryways:0);
    // exclude ways with tag highway=* which are part of the boundary relation
    (._; - way.boundaryways[highway];);
    // print result
    out geom;