I want to get the city boundaries within a specific country. The following query is fast but it's not bound to a country so that multiple city boundaries could be returned.

[out:json];(rel[name='Herne'][type=boundary];);out geom;

I tried this query but it's extremely slow:

( area["ISO3166-1:alpha2"="DE"];) ->.a;
out geom;

Is there a better and faster solution?

asked 21 Jun '18, 14:41

OsmStorm's gravatar image

accept rate: 0%

I've tried myself your slow query and it took me 90 seconds. Bear in mind that it hasn't the filter [type="boundary"].

This one takes about 50 seconds, and does the same (it includes the [type="boundary"] filter):

out geom;

From my experience so far with Overpass, it takes normally a similar time for queries over a country of the size of Germany. But maybe somebody has a faster solution.

permanent link

answered 23 Jun '18, 17:23

edvac's gravatar image

accept rate: 13%

Thanks for your answer! But why is this query so much slower than the first one? The first one takes like 1-2 seconds compared to 50/90 seconds. I guess it would be faster to take one coordinate per polygon (city) and check via another query if it's inside the given country or not. If someone finds a faster query or any other faster solution, please let me know.

(26 Jun '18, 07:06) OsmStorm

Is there maybe a way to detect which polygon belongs to which country by only going through the osm or geojson print? Maybe by help of the tags?

Herne Germany:

 "tags": {
    "TMC:cid_58:tabcd_1:Class": "Area",
    "TMC:cid_58:tabcd_1:LCLversion": "8.00",
    "TMC:cid_58:tabcd_1:LocationCode": "463",
    "admin_level": "6",
    "boundary": "administrative",
    "de:amtlicher_gemeindeschluessel": "05916000",
    "de:place": "city",
    "de:regionalschluessel": "059160000000",
    "name": "Herne",
    "name:prefix": "Stadt",
    "source": "http://wiki.openstreetmap.org/wiki/Import/Catalogue/Kreisgrenzen_Deutschland_2005",
    "type": "boundary",
    "wikidata": "Q2904",
    "wikipedia": "de:Herne"

Herne Belgium:

"tags": {
"admin_level": "8",
"boundary": "administrative",
"name": "Herne",
"name:ru": "Херне",
"ref:INS": "23032",
"type": "boundary",
"website": "http://www.herne.be",
"wikidata": "Q567808",
"wikipedia": "nl:Herne (België)"


But here, I could only take the wikipedia entry and decide by the prefix "de" / "nl" whereas "nl" would be wrong if I was looking for a Herne in the Netherlands.

permanent link

answered 26 Jun '18, 07:56

OsmStorm's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



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:


question asked: 21 Jun '18, 14:41

question was seen: 1,455 times

last updated: 26 Jun '18, 07:56

powered by OSQA