[OSM-talk] Overpass API - Fetching countries, their capitals, and their borders

Léo El Amri leo at superlel.me
Wed Aug 14 15:17:31 UTC 2019


I was doing a query for all city and towns before doing a query of all
"capital=yes" in this set. This was only the result of the interserction
that was sent to the output.

I didn't really knew how to "OR" the filters. Now I see, and your
solution looks better :)

On 14/08/2019 14:51, Dave F via talk wrote:
> This may help for future routines, if not this one:
> 
> nwr[place~"city|town"][capital=yes][admin_level=2]->.Capitals;
> .Capitals out center;
> 
> in your original you were initially searching *all* of the world's towns
> & cities instead of 194 capitals. (OSM appears to be missing one)
> 
> It'll need checking but I think all capital cities should be returned as
> members in the set of boundary relations with the role of 'admin_centre'.
> 
> https://overpass-turbo.eu/s/Lwe
> 
> [bbox:{{bbox}}];
> rel[boundary=administrative][admin_level=2];
> nwr(r:admin_centre);
> out center;
> 
> You appear to be outputting both boundary relations & ways which seems a
> bit pointless
> This returns all ways within the relations:
> https://overpass-turbo.eu/s/Lwk
> 
> [bbox:{{bbox}}];
> rel[boundary=administrative][admin_level=2];
> way(r._);
> out geom;
> 
> HTH
> DaveF.
> 
>> On 13/08/2019 23:41, Léo El Amri via talk wrote:
>>> Hello,
>>>
>>> I'm trying to fetch countries, their borders, and their capitals through
>>> Overpass API, but the server never replies to me (With a timeout:3600
>>> setting, the server reply with a 502 error after a while).
>>> I'm only a beginner with this API, so maybe my request is not efficient:
>>>
>>> (
>>>    node[place=city];
>>>    node[place=town];
>>> )->.a;
>>> rel[boundary=administrative][admin_level=2]->.b;
>>> (
>>>    node[place=country];
>>>    node.a[capital=yes];
>>>    way[boundary=administrative][admin_level=2];
>>>    .b;
>>>    .b >;
>>> )->.o;
>>> .o out body;
>>>
>>> What am I doing wrong ? (Should I use another tool for this purpose ?)
>>>
>>> Cordially,
>>> Léo



More information about the talk mailing list