openstreetmapoverpass-api

Finding a particular house number near to major roads


I'm trying to construct an Overpass query to return all 3-storey houses of a particular house number that are near to major roads. I understand that this involves an 'around' filter, probably, but I can't figure out how to include it. What I have at the minute (for Overpass Turbo) is:

[out:xml][timeout:25];
(
    node["addr:housenumber"="26"]["building:levels"="3"]({{bbox}});
    way["addr:housenumber"="26"]["building:levels"="3"]({{bbox}});
    relation["addr:housenumber"="26"]["building:levels"="3"]({{bbox}});  
);
out meta;
>;
out meta qt;

Solution

  • This is inspired by the overpass wiki (https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Relative_to_other_elements_(around))

    Create a set with your major roads, then do an 'around' filter on that set, here 50m: (It was hard to find a city with results...). You could do a union, or use a regex key search if you want to search primary and secondary roads.

    area[name="London"];
    way(area)[highway=primary]->.major_roads;
    (   node(around.major_roads:50)["addr:housenumber"="26"]["building:levels"="3"];
      way(around.major_roads:50)["addr:housenumber"="26"]["building:levels"="3"];
     area(around.major_roads:50)["addr:housenumber"="26"]["building:levels"="3"];
    );
    out meta;
    >;
    out meta qt;