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

Hey all,

whilst I thought I was somewhat getting the hang over the Overpass API, a fairly basic usecase has me stumped!

I want to extract the enclosing administrative boundary when providing a lat and long, looking to extract levels 10, 9 and 8.

I have been able to extract all surrounding relations by doing the following query, which pulls back far too much information including the county, country and UK as a whole:

    is_in(52.0246,0.80801)->.a;way(pivot.a);out tags ;relation(pivot.a);out tags bb;

I have tried to limit the results with:


and various relations but that hasn't limited the results at all. Could someone please help? Much appreciated!

asked 14 Jul '21, 20:51

nikotime's gravatar image

accept rate: 0%

If you want only those relations tagged with admin_level=10 you can say it when requesting them:

out tags bb;

If you want even those with admin_level 8 and 9 then the code gets slightly larger:

relation(pivot.a)(if:t["admin_level"]>=8 && t["admin_level"]<=10);
out tags bb;
permanent link

answered 15 Jul '21, 11:57

MarcoR's gravatar image

accept rate: 23%

Thats absolutely spot on. Thanks so much Marco for your help!

(16 Jul '21, 08:16) nikotime
out geom;

No requirement to store output in a variable (a) if only to be used once. Pivot will used the default output.

Regex is used to filter the required admin_level. Note the 'something like' symbol.

Pivot converts area to objects.


To output just the tags there's no need to pivot

out tags;

PS If you're just wanting to output a list, maybe take a look at out:csv.

permanent link

answered 22 Aug '21, 18:50

DaveF's gravatar image

accept rate: 16%

edited 22 Aug '21, 19:21

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: 14 Jul '21, 20:51

question was seen: 1,099 times

last updated: 22 Aug '21, 19:21

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