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

Hi, I have the following query which returns the boundary relation for Spain along with the ways it references and the nodes that these ways reference. area["ISO3166-1"="ES"][admin_level=2]; (relation["boundary"="administrative"]["admin_level"="2"]"name:en"="Spain"; way(r); node(w); );out; I get lots of ways and their nodes returned based on the members where type="way". I do not get the two member entries where type="node" though. I have tried adding node(r) to my query but doing this seems to block getting the ways. Is there a single query that will get me ways (and their nodes), and the member nodes of the relation? Many thanks, Chessel

asked 20 Dec '23, 20:41

Chessel's gravatar image

Chessel
11556
accept rate: 0%

1

You need to post the actual routine you ran as the code above has errors. Use code formatting &/or post a link (use the Share button). What is it you're attempting to output. It's not very clear. Edit: I've simplified it a bit for you: https://overpass-turbo.eu/s/1Fc8

(24 Dec '23, 15:05) DaveF

Hi, my replying comment is too long so I'll will do an answer.

(24 Dec '23, 16:28) Chessel

Hi Dave, thanks for your answer. Sorry my question isn't clear. The reason why my question is formatted poorly is I'm not using the overpass web site as I'm a blind user and visual renderings of my results don't help me. I need to examine the results of my queries by looking at the raw data returned. So I make an http call to overpass in my browser which gets me a file back I can then analyze.

My aim is to download the relation that relates to a given country describing its border at admin level 2. The relation has <member> elements which reference nodes, ways and relations. I don't want the relations referenced here but I do want to retrieve the nodes referenced, plus the ways. And for those ways, I want to retrieve the nodes they reference.

My entire call is: http://overpass-api.de/api/interpreter?data=area["ISO3166-1"="ES"][admin_level=2];(relation["boundary"="administrative"]["admin_level"="2"]"name:en"="Spain";way(r);node(w););out;

The key parts are:

area["ISO3166-1"="ES"][admin_level=2];

(relation["boundary"="administrative"]["admin_level"="2"]"name:en"="Spain";

way(r);

node(w);

);

out;

At the moment, this query gets me the main relation for Spain, the ways it references, and the nodes these ways reference. It omits the nodes directly referenced by the relation in <member> tags. Okay, there are just two of them, but I still want them.

Hope this is clearer.

Kind regards.

permanent link

answered 24 Dec '23, 16:28

Chessel's gravatar image

Chessel
11556
accept rate: 0%

This requires two separate replies as the problem may relate to other threads on github & needs further investigation.

First post: syntax problems with your routine as is.

You have no square brackets around "name:en"=Spain; so your routine returns an error.

There is no requirement for [admin_level=2] as all ISO3166-1 areas are the same admin_level

area["ISO3166-1"=ES]; is the same as your second line so you're duplicating data.

Edit: Add 'geom' to the 'out': https://overpass-api.de/api/interpreter?data=area["ISO3166-1"=ES];(rel(pivot);way(r);node(w););out geom;

Use either:

area["ISO3166-1"=ES];(rel(pivot);way(r);node(w););out;

or

(rel[boundary=administrative][admin_level=2]["name:en"=Spain];way(r);node(w););out;

Edit: Add 'geom' to the 'out': https://overpass-api.de/api/interpreter?data=area["ISO3166-1"=ES];(rel(pivot);way(r);node(w););out geom;

permanent link

answered 24 Dec '23, 22:04

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 24 Dec '23, 22:38

Hi Dave, Thanks for tidying up my query. I see how I was duplicating info in my request.

My original problem is still present however. The relation for Spain has ID 21068295. It references two nodes:

<member type="node" ref="21068295" role="admin_centre"/>

<member type="node" ref="148332300" role="label"/>

And these are not returned by the query.

I have tried adding node(r) but this makes no difference.

So is there a way to retrieve all the data the query currently does plus the <node> entries for the two nodes referenced directly by the member?

I also don't see the value in adding 'geom' to my out clause. It looks like it adds bounding box info but I'll be calculating these as my application interprets the XML data I retrieve.

Thank you for any further help you can give, Chessel

permanent link

answered 25 Dec '23, 19:46

Chessel's gravatar image

Chessel
11556
accept rate: 0%

They are in mine:

<member type="node" ref="21068295" role="admin_centre" lat="40.4167047" lon="-3.7035825"/> <member type="node" ref="148332300" role="label" lat="39.3260685" lon="-4.8379791"/>

Are you sure you're copy pasting the url I gave you with geom at the end? The resulting file contains them. Search for just the ref value.

(26 Dec '23, 01:33) DaveF

Hello Dave,

I used the first variation you suggested and included the geom keyword. This downloads about 5.7Mb of xml compared to about 3.3Mb without the geom tag.

I don't see the two relation nodes, ref="21068295" and ref="148332300", except in the <relation element="" itself.="" the="" geom="" keyword="" does="" mean="" the="" coordinates="" are="" also="" part="" of="" the="" <member=""> tag info for the nodes but not the node tags.

Looking at the whole file... finding the first node in the downloaded file with a tag is node with id="26864258". which has about 16 tags.

The whole download has a structure of nodes first, then ways, then the relation.

I'd like, if possible, to have the two nodes ref="21068295" and ref="148332300" included in the rest of the nodes area of the download.

If it isn't possible then so be it and I'll have to do a second call to get them but would be simpler to have everything for a relation come down in one call.

Kind regards, Chris

permanent link

answered 27 Dec '23, 10:50

Chessel's gravatar image

Chessel
11556
accept rate: 0%

area["ISO3166-1"=ES];rel(pivot);(nw(r);node(w););out;

permanent link

answered 27 Dec '23, 13:33

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

Hi Dave,

That works, thank you. I moved the rel(pivot) inside the brackets otherwise the relation itself wasn't downloaded. But now I get all the nodes and ways for the relation including the two nodes referenced by the relation directly.

Now all I need to do is debug my code which reads in this 3.3Mb of data so my laptop doesn't fall over because I allocate memory in an un-ending loop somewhere.

Thanks again, Chessel

permanent link

answered 27 Dec '23, 20:51

Chessel's gravatar image

Chessel
11556
accept rate: 0%

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
×205
×128

question asked: 20 Dec '23, 20:41

question was seen: 1,506 times

last updated: 27 Dec '23, 20:51

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