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

Warin 61sundowner at gmail.com
Tue Aug 13 22:30:24 UTC 2019

On 14/08/19 07: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 ?)

Too much data? So it times out.

You are asking for every node of;

city 19,930

town 111,981

country 221

And then boundaries as well. 29,752

The numbers I got from taginfo.. did not bother with separating nodes etc.

I think the boundaries will cause problems - lots of nodes and ways in there as well as the relations.

Suggestions? Do it in small sections.

Get the cities and countries as one item and see if that works. Save the result for later merging.

Get the boundaries for a small section of the world .. with few boundaries and see if that works.

More information about the talk mailing list