0

I have a geometrical line and I would like to have all intersection points where this line passes roads.

So far I have a line, defined by coordinates. I am looking for all intersection points with roads:

way(40.73792521975707,-74.00163173675537,40.743062717636114,-73.98819923400879);
   (way["highway"~"primary|secondary|tertiary|trunk|service|residential"];
    node(w););
out meta;

As an output I expect a series of points where this line crosses roads and such.

https://overpass-turbo.eu/s/BZB

  • 1
    the Overpass API does not provide functions for e.g. geometric intersections; the Overpass QL Intersection function will return all nodes that are common in both input sets. consider QGIS instead, as it provides user friendly access to OSM data for your AOI and the necessary functions. – ThingumaBob Sep 18 '18 at 10:42
  • you will need to load the osm data into postgis and use the ST_Intersection postgis.net/docs/ST_Intersection.html function. – Mapperz Sep 18 '18 at 12:57
1

You can use following examples from Overpass API by Example as a starting point to easily achieve what you're looking for.

Find intersections of major and minor roads:

[bbox:{{bbox}}];
way[highway~"^(motorway|trunk|primary|secondary|tertiary|(motorway|trunk|primary|secondary)_link)$"]->.major;
way[highway~"^(unclassified|residential|living_street|service)$"]->.minor;
node(w.major)(w.minor);
out;

Please adjust major/minor according to your requirements.

To find intersections without a common node, you can use way(around:0). The documentation on "around" explicitly mentions "A radius of 0 can be used for a way intersection test on outer/inner points.".

There are also multiple examples in this guide, such as "n adjacent ways", which returns such ways. To get the exact lat/lon locations for the intersection point (e.g. no OSM node exists in the data), you indeed need some post processing.

  • you are exactly right; way[highway](around:0,40.73792521975707,-74.00163173675537,40.743062717636114,-73.98819923400879);(._;>;);out geom; – API Sep 24 '18 at 15:49
  • I expected the post-processing, but no problemo – API Sep 24 '18 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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