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

I want to export all relations with tags such as boundary=administrative and all childs of those relations in a certain area.

I'm using Overpass API, but I get stuck with the variables. My current code looks as following (with Staden as an example, bigger areas will be used once it works):

area[name="Staden"];
(
  node(area);
  <;
) -> .a;
(
  .a rel["boundary"="administrative"];
);
out meta qt;

But it doesn't work. 'a' is supposed to be a variable holding all features in Staden. And then, according to the documentation I've read, I should be able to use 'a' to get all relations with specific tags in it.

Once I have the relations, they should be completed again so I have an OSM file that can be displayed.

And I hope, once the syntax error is resolved, that the query doesn't include boundaries of neighbour villages. If anyone has an idea on how to get those out, you would be very welcome.

It might also be a good example to put on the wiki.

asked 11 Dec '12, 14:52

Sanderd17's gravatar image

Sanderd17
1.1k51637
accept rate: 31%

edited 11 Dec '12, 14:52

Ping, are there no OpenLayers specialists here?

(13 Dec '12, 13:09) Sanderd17
1

OverpassAPI, not OpenLayers. Be a bit more patient, Roland Olbricht is stopping by from time to time. He should be able to help you.

(13 Dec '12, 13:55) scai ♦

Please put the ".a" after "rel". Otherwise, you should have seen a syntax error:

area[name="Staden"];
(
  node(area);
  <;
) -> .a;
(
  rel.a["boundary"="administrative"];
);
out meta qt;

The syntax is here different from the syntax of "out", because it does something different: It reads "take all relations that are contained in .a and have a tag with the given values". In particular, you could intersect in a query multiple sets like "rel.a.b" which is not possible in the context of "out".

Thank you for asking this question. I'll copy this explanation to the documentation. Please add a link fomr the wiki to this question meanwhile to remind me on this.

I'm sorry for the late answer. I try in general a 24h hour check about relevant questions, but for no apparent reason I missed this one. In such a case, please feel free to write me an email to roland.olbricht at gmx.de.

permanent link

answered 17 Dec '12, 07:15

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

edited 17 Dec '12, 07:17

No problem, I wasn't in a hurry, it's just that I didn't want the question to fall of the first page.

It works great now.

(17 Dec '12, 12:13) Sanderd17

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
×315
×213

question asked: 11 Dec '12, 14:52

question was seen: 7,429 times

last updated: 17 Dec '12, 12:13

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