I need to find intersection by searching name of 2 streets; I found 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?
2 Answers
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?– NazilaJan 4, 2015 at 10:44
-
1It'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).– mmdJan 4, 2015 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– NazilaJan 4, 2015 at 10:50
-
overpass-turbo.eu/s/6Pf It just finds 2 node in Iran and of course not the one i mean– NazilaJan 4, 2015 at 10:58
-
1You 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.– mmdJan 4, 2015 at 11:02
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).