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

I'm trying to output a file in Overpass Turbo, let's assume CSV (because it seems easier to accomplish this with CSV), with:

  • All nodes in Portugal where the tag capital=yes or capital=1 or (...) or capital=7
  • For all those nodes, output the following information: name (tag), capital (tag) and coordinates and find the rel with the tag border_type=distrito (or admin_level=6) they belong to, and output it's name as well.

Example output:

namecapitallatlngparent
City_1738.123-9.123County_1
City_2238.123-9.123County_1
City_3438.123-9.123County_2
City_4438.123-9.123County_3
City_5438.123-9.123County_2


I've managed to output all info correctly except for the parent information, with this Overpass Turbo query:

[out:csv(name,capital,::lat,::lon;true;";")][timeout:250];
{{geocodeArea:Portugal}}->.searchArea;

(
  node["capital"="yes"](area.searchArea);
  node["capital"="1"](area.searchArea);
  node["capital"="2"](area.searchArea);
  node["capital"="3"](area.searchArea);
  node["capital"="4"](area.searchArea);
  node["capital"="5"](area.searchArea);
  node["capital"="6"](area.searchArea);
  node["capital"="7"](area.searchArea);
);

out body;
>;
out skel qt;

However, I'm having a hard time figuring out how to get which admin_level=6 each place belongs to. Any help would be greatly appreciated.

asked 15 Nov '20, 23:59

FSeixasPT's gravatar image

FSeixasPT
11112
accept rate: 0%


Unsure if it's possible, but try looking at recursion (to get the relation on the way) & the 'for' block command in the wiki & here: https://dev.overpass-api.de/blog/index.html (unfortunately it's isn't searchable. you'll have to go through each page individually)

Compacted version of your routine using RegEx:

[out:csv(name,capital,::lat,::lon;true;";")];
{{geocodeArea:Portugal}};
node[capital~"yes|[1-7]"](area);
out meta;
permanent link

answered 17 Nov '20, 19:57

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 17 Nov '20, 20:02

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
×228

question asked: 15 Nov '20, 23:59

question was seen: 1,097 times

last updated: 17 Nov '20, 20:02

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