NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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 ♦

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.

permanent link

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

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×202

question asked: 08 Oct '18, 16:40

question was seen: 1,915 times

last updated: 09 Oct '18, 08:26

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum