5

I need to find intersection by searching name of 2 streets; I fonud overpass API to query on osm data; the way i found was to find a node near a way; but the problem is all nodes don't have name and in most cases the answer isn't accurate,Is there a better way?

7

You could use the following approach:

[bbox:{{bbox}}];
way[highway][name="6th Avenue"];node(w)->.n1;
way[highway][name="West 23rd Street"];node(w)->.n2;
node.n1.n2;
out meta;

Try it on overpass turbo: http://overpass-turbo.eu/s/6Pb

Edit: node.n1.n2; calculates the intersection of input set .n1 and .n2. Please check the documentation for details.

  • Thank's that helped so much. but what does node.n1.n2 do? how can i see all possible answer and not just one? – Nazila Jan 4 '15 at 10:44
  • 1
    It's the just intersection of all nodes in inputset .n1 and .n2. You will always get ALL possible answers in the area you specify: just remove the [bbox:{{bbox}}] in the first line to get 3 of those intersection worldwide (all of them in the US). – mmd Jan 4 '15 at 10:47
  • Thank you I did and yet I didn't get the correct intersection, I guess it's because of limitation of map data, Iran osm map isn't complete – Nazila Jan 4 '15 at 10:50
  • overpass-turbo.eu/s/6Pf It just finds 2 node in Iran and of course not the one i mean – Nazila Jan 4 '15 at 10:58
  • 1
    You could check if both ways are in your result: overpass-turbo.eu/s/6Pg Also, it is important that both ways technically share at least one node. If they just intersect but don't have that common node, you would have to look into the around filter instead. – mmd Jan 4 '15 at 11:02
2

Works fine for me. Could be enhance.

[bbox:{{bbox}}];
(way[highway="motorway"];way[highway="trunk"];way[highway="primary"];way[highway="secondary"];way[highway="tertiary"];way[highway="unclassified"];way[highway="track"];way[highway="service"];way[highway="residential"];)->.n1;
foreach.n1(
    (.n1; - ._;)->.n2;
    node(w._)->.n3;
    node(w.n2)->.n2;
    node.n3.n2;
    out;
  );

http://overpass-turbo.eu/s/bkD

It keeps crossing, if you don't need it, just substract the set of crossing to the intersection node (node.n3.n2).

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.