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

I am searching for a map of sub-districts (admin level 6) within a district(admin level 5) in which each sub-dist will be clickable on my webpage. The problem is there are some districts with one of its sub-district having same name as the district itself. when I search for the district I get the sub-district instead.

Sub District with same name alt text

What i wantalt text


{{geocodeArea: chittoor, Andhra Pradesh, india}}->.searchArea;


  relation["type"="boundary"][admin_level = 6](area.searchArea);


    relation[admin_level = 6];
out skel;

Here i am trying to use output of one set as input for next set? How can i archive this?

asked 06 Dec '20, 17:36

PramodG's gravatar image

accept rate: 0%

edited 07 Dec '20, 18:49

TZorn's gravatar image


I think you cant rely on geocodeArea for this type of operation. Instead you will need an unambiguous search string using standard overpass syntax (for instance possibly based on the wikidata item) and convert that to an area using the overpass statement which can then be assigned to the .searchArea set, something like area[wikidata="Q11103437"]->.searchArea;. (Of course if you know the object's OSM Id you can access the area by adding a magic number to the id).

permanent link

answered 06 Dec '20, 18:55

SK53's gravatar image

SK53 ♦
accept rate: 22%

I am doing something like that in python, but geocode return list (geo_result VARIABLE) of location matching the district name so both the sub-district and district are returned. How can i select the right one?

geolocator = Nominatim(user_agent="city_compare") geo_results = geolocator.geocode(dist_name, exactly_one=False)

Searching for relation in result set

for r in geo_results: #print(r.address, r.raw.get("osm_type")) if r.raw.get("osm_type") == "relation" and r.raw.get('type')=='administrative': city = r break # Calculating area id area_id = int(city.raw.get("osm_id")) + 3600000000 #print(area_id) # Excecuting overpass call query2 = """ [out:json]; area({})->.searchArea;

           relation["type"="boundary"][admin_level = 6](area.searchArea);
      out geom;""".format(area_id)
   url = ''
   r= requests.get(url, params={'data': query2})
(06 Dec '20, 19:10) PramodG

Ah, my approach gets round this Nominatim issue in Overpass, but does not resolve the actual Nominatim issue.

(07 Dec '20, 13:03) SK53 ♦

It will probably work to use the place_rank in the Nominatim results. If it doesn't, query Nominatim or Overpass-API for the details of each candidate (at which point you will have the admin_level tag).

(07 Dec '20, 21:47) maxerickson

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: 06 Dec '20, 17:36

question was seen: 1,258 times

last updated: 07 Dec '20, 21:47

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