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

How do I make a query that returns me every admin_level=7 relation in Poland that doesn't have a member with admin_centre role?

This is a pre-requisite to another thing - After fixing these (if needed, I wanna find out) I want to list every place in Poland that should feature amenity=townhall, but has none. This is what I've got currently: http://overpass-turbo.eu/s/dJo

In this second query I also have to solve a problem: Some rural municipalities have their seat outside them, how do I exclude these? cf. https://en.wikipedia.org/wiki/Gmina

asked 15 Jan '16, 01:58

RicoElectrico's gravatar image

RicoElectrico
37161117
accept rate: 0%

edited 15 Jan '16, 21:42

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


I will focus on your first question atm. If possible, please move your other question to dedicated threads.

Here's how the query should look like

[timeout:600];

area[admin_level=2]["name"="Polska"][boundary=administrative]->.boundaryarea;

( rel(area.boundaryarea)[boundary=administrative][admin_level=7]; -

  ( node(r:"admin_centre")->.a;
    rel(bn.a)[boundary=administrative][admin_level=7]; 
  );
);

out geom;

Overpass Turbo Link: http://overpass-turbo.eu/s/dLT

A few words how this works:

  • We initially get a boundaryarea as defined per Poland's admin_level=2 boundary
  • Now we determine difference of all admin_level=7 boundaries in that area MINUS those admin_level=7 boundaries having an admin_centre node.

Read more about the recurse functions used in this query here.

Note that there are some relations returned outside of Poland. This is not a bug in the query, but rather some outdated areas on overpass-api.de. See this thread for details. It works just fine on our dev box with up-to-date areas.

permanent link

answered 15 Jan '16, 20:11

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

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

question asked: 15 Jan '16, 01:58

question was seen: 3,072 times

last updated: 15 Jan '16, 21:42

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