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

[out:json];

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

(

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

);
out;

(
    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

PramodG
11224
accept rate: 0%

edited 07 Dec '20, 18:49

TZorn's gravatar image

TZorn
12.3k664223


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 ♦
27.6k47267427
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 = 'https://overpass-api.de/api/interpreter'
   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
Your answer
toggle preview

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:

×4
×4

question asked: 06 Dec '20, 17:36

question was seen: 660 times

last updated: 07 Dec '20, 21:47

powered by OSQA