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 What i want
Here i am trying to use output of one set as input for next set? How can i archive this? |
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). answered 06 Dec '20, 18:55 SK53 ♦ 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 setfor 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;
(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
(07 Dec '20, 21:47)
maxerickson
|