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

3
2

I have a simple overpass query based on is_in that does half of what I need - finds an area tagged as a building if one surrounds my input co-ordinates. So here's what the query looks like for "The Shard" in London:

is_in(51.5041386,-0.0862526); foreach(area._["building"];out;);

I'd like to also pull back the full geometry (ways and nodes) of the outline (indeed it'd be nice for this to work for buildings made as relations too, but let's not be greedy just yet). It seemed like one of the recurse options might do that, but I tried all I could think of to no avail. I'm guessing I'm missing an important piece. Can anybody show me what?

Thanks!

asked 20 Feb '13, 17:27

mackerski's gravatar image

mackerski
121146
accept rate: 0%


I'm sorry, there exists no direct implementation yet for this feature.

However, there are two effective workarounds for this: You could query the ways that are inside the area and have appropriate tags:

is_in(51.5041386,-0.0862526);foreach(area._["building"]["name"];way(area)["building"]["name"];out;);

As buildings usually don't overlap, this should almost always return the right object. And it would work for relations as well if there were any:

is_in(51.5041386,-0.0862526);foreach(area._["building"]["name"];rel(area)["building"]["name"];out;);

The downside is that this doesn't work properly with terraced houses, because the neighbouring house is considered as inside the area if it touches the area with a complete edge.

The second workaround would be to evaluate the area id: - An area with an id between 2.4 billion and 3.6 billion is always created from the way with area id minus 2.4 billion. - An area with an id of more than 3.6 billion is always created from the relation with area id minus 3.6 billion.

You would have to do two requests to use this workaround: the first fetches the ids, and then the second, like

(way(31110737);>;);out;

fetches the actual geometry.

As this could be easily done on the server, I'll include a command for this workaround in the next version. This would also be sustainable if the numbering scheme for areas changes in the future. I'll post details here once a beta version is operational, in a couple of days.

permanent link

answered 21 Feb '13, 09:55

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

1

Helps a lot, thanks! I modified my basic query to this:

is_in(51.5041386,-0.0862526);foreach(area._["building"];out;
way(area)["building"];out;
>;out;);

This does something very like what I want:

  • Data includes the area ID of the shape I actually want, so I can apply simple post-processing to discard any non-matching ways
  • I get full geometry back in a single query

Open question: the revised query above will match only building ways, not relations. I can run a second copy, but is there a nice way to also include relations in the same query?

(21 Feb '13, 10:36) mackerski

This answer doesn't seem to work any more? Trying this query on the Overpass Turbo site (http://overpass-turbo.eu/s/jxk), it returns an empty set. The original question's query does return the appropriate area object, but converting back to the way that represents it isn't working.

(21 Oct '16, 21:56) Midnightligh...

Please try

is_in(51.5041386,-0.0862526); foreach( area._["building"]["name"]; way(pivot);out geom; );

(22 Oct '16, 09:10) Roland Olbricht

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

question asked: 20 Feb '13, 17:27

question was seen: 18,095 times

last updated: 22 Oct '16, 09:10

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