NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum

I'm using the Overpass API to pull data from OpenStreetMap. The web version that I use to verify queries before running through my process against the API is Overpass Turbo.

This is the query I'm using to collect all places that are Admin Level 8 within California:

[out:json]; area['admin_level'='4']['name'='California']; (relation['admin_level'='8'](area);); out;

That doesn't return all items, though. For example, Pacifica is not included.

Is that a problem with Overpass, or is there something wrong with my query?

asked 25 Oct '15, 20:26

JamesChevalier's gravatar image

accept rate: 25%

Pacifica is a way. So you need to also have a way query (or just use an area query).

out geom;

or the mostly equivalent (mmd points out in a comment that this won't work as it is not implemented):


I guess the area query will probably be cleaner, as it will only return closed polygons (depending on what's in the data, there might be a bunch of ways that aren't closed areas).

permanent link

answered 25 Oct '15, 20:57

maxerickson's gravatar image

accept rate: 32%

edited 25 Oct '15, 21:20

mmd's gravatar image



area['admin_level'='8'](area); looks correct, but unfortunately it is not implemented and doesn't work as you would expect: it just returns areas matching admin_level = 8, without taking the (area) part into consideration. Also, you will not get any error message whatsoever, but simply a 60MB response with admin_level=8 areas from all over the world.

Bottom line: you have to stick to rel...(area) / way...(area) for the time being.

(25 Oct '15, 21:05) mmd

The biggest issue is that it will probably return ways that are parts of the relations (but with any luck you will be able to discard those by checking for things like 'name').

(25 Oct '15, 21:14) maxerickson

@maxerickson: I had to adopt your initial proposal, as it also didn't work as expected: you need to store the area in an inputset (here it is called .ca) and use that for both relation and way. Otherwise, the relation query will silently remove the California area, and way (area) will not find anything, as there's no more area to work on.

(25 Oct '15, 21:21) mmd

Thank you! Thank you! Thank you! You both just helped me out so much. In case it's at all useful to anyone, I've been storing the individual cities that I'm using in my project in github:

(25 Oct '15, 21:32) JamesChevalier

Oh wow, I just realized how critical that last geom you added is! Thanks.

(25 Oct '15, 21:53) JamesChevalier
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]( "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: 25 Oct '15, 20:26

question was seen: 3,623 times

last updated: 25 Oct '15, 21:53

NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum