This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Address nodes inside buildings

0

How can I find nodes with "addr:housenumber" inside buildings with Overpass? I've found this snippet, but it doesn't work:

way[building=yes]
   ({{bbox}});
   (node(around:0)["addr:housenumber"~"."];
    node(w););
out meta;

asked 08 Oct '18, 16:40

Norske's gravatar image

Norske
11223
accept rate: 0%

Just curious, why do you need this query?

(09 Oct '18, 07:51) scai ♦

One Answer:

0

Well, here's a script that will get you some results, but it isn't really correct:

[timeout:30];
way[building]({{bbox}});
( 
  node(around:5)["addr:housenumber"];
);
out meta;

Some things to note:

  • Rather than just building=yes, I'm just checking if the building tag exists, so it will work with building=school, building=apartments, etc.
  • Rather than using a regex match on the addr:housenumber tag, I'm again simply checking that the tag exists, which is more efficient.
  • I've used a value of 5 meters for the around() filter. This will find all address nodes within 5 meters of... something. Truth is, I don't really understand how around() works with ways. It doesn't mean within 5 meters of the interior. If it did, 0 (or at least 1) would work. By trial-and-error, it doesn't seem to mean within 5 meters of the center, either. Nonetheless, if you're dealing with larger buildings, you may have to increase this number to catch the address nodes -- at the risk of false positives, if there are address nodes outside but near the buildings.

If there's a way to actually filter whats inside the perimeters of the buildings, rather than using around() to find what's nearby, I'd love to see that script.

answered 08 Oct '18, 21:24

jmapb's gravatar image

jmapb
3.4k73361
accept rate: 22%

edited 08 Oct '18, 21:30

But with around I can't really check whether the node is inside or outside: https://overpass-turbo.eu/s/CBX

(08 Oct '18, 21:52) Norske

That's right -- it gives both false positives and false negatives. That's why I said it isn't really correct. I'd like to know the correct answer too, if there is one!

(09 Oct '18, 00:54) jmapb
1

This enhancement request may be relevant https://github.com/drolbr/Overpass-API/issues/77

(09 Oct '18, 08:26) andrewblack