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

I'm facing runtime errors for big countries and if it succeeds the browser crashes. I'm actually using this qeury in a python script

[out:json][timeout:350];
    area(3600365331)->.searchArea;
    (
      way["boundary"="administrative"](area.searchArea);
      relation["boundary"="administrative"](area.searchArea);
    );
     (._;>;);out body;

Is there anything I'm doing wrong ? or is there any better query for what I want ? https://drive.google.com/file/d/1WGWKxXpW3s0xee-JU2E_9rXL_5vAxIZo/view?usp=sharing

asked 23 Jun '21, 09:00

Jad's gravatar image

Jad
26113
accept rate: 0%

edited 23 Jun '21, 16:58

TZorn's gravatar image

TZorn
12.3k764225


First, a general point: Could contributors, other than the OP, not alter the original question. It can make any replies appear to be nonsense & confuse those trying to learn. A part of Jad's problem was the syntax of the code. To correct it, an Answer should have been provided.

There are two answers to this Q

1) As as @mtmail suggests use the boundary site, where they have already been saved & segregated off the main server.

2) Going on JAD's original code as posted, the routine wouldn't have run, & even when corrected would probably have timed out for the whole of Italy.

This adapted routine is restricted to the visible area & to boundaries of only one admin level: https://overpass-turbo.eu/s/18Nl

[bbox:{{bbox}}];
rel[boundary=administrative][admin_level=4];
out geom;

There is no need to search for boundary ways as all should be mapped as rels.

permanent link

answered 24 Jun '21, 13:34

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

Dave. I merely formatted the query as code (with the grey background) as it was displayed as a single long line before. I didn't alter it in any way. And I shortened the title which ran over several lines and put the question in the text instead. Both served to make the question better readable but I didn't change anything in the content.

(24 Jun '21, 14:44) TZorn

Hello.

Boundaries are huge, thus I think mtmail's answer is probably the best way.

But if you really need to go through overpass, first you should simplify your request. You don't need to ask for the ways, as they will be children of the relation. That should lighten the burden of the server if you don't ask the same objects twice.

Then, the search area is not precise enough, in your example (targeting Italy) I got the whole boundary of France and some of its regions. Maybe "is_in" might be better.

Also, do you really need every kind of boundaries there is ? National parks, municipality, voting zones, and so on. Maybe you could filter with admin_level. Trouble is that it's not totally consistent across every country, but I think it's thoroughly documented in the wiki (boundary, admin_level and subpages).

Good luck.

Regards.

permanent link

answered 24 Jun '21, 11:05

H_mlet's gravatar image

H_mlet
5.4k1781
accept rate: 13%

Have a look at https://osm-boundaries.com/ On the left-hand side in the country structure you can right-click and select all children (or only those you need). After clicking the download button you'll be asked which data format you require.

permanent link

answered 23 Jun '21, 11:19

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Your answer
toggle preview

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:

×710
×689
×483
×228
×147

question asked: 23 Jun '21, 09:00

question was seen: 2,067 times

last updated: 24 Jun '21, 14:44

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