I am looking district names of India with state names as CSV format.
I tried to write an overpass query but it is not working. Please let me know what I am doing wrong. Is there any other simple query also. I am looking only from Overpass API not from any other data provider.
[out:csv(::type,::id,admin_level,name,"name:en","country","admin_level_4_name")];
rel["name:en"="India"]->.rel;
map_to_area->.a;
(
rel[admin_level=4](area.a)->.admin_level_4;
rel[admin_level=5](area.a)->.admin_level_5;
foreach.admin_level_5(
out center ->.ctr;
.ctr is_in->.admin_level_4_relation;
.admin_level_5 set admin_level_4_name = .admin_level_4_relation["name"];
out;
);
);
out;
Update 1:
I am adding here the overpass-turbo error:
An error occurred during the execution of the overpass query! This is what overpass API returned:
Error: line 10: parse error: Invalid parameter for print: "->"
Error: line 10: parse error: Invalid parameter for print: "."
Error: line 10: parse error: Invalid parameter for print: "ctr"
Error: line 12: parse error: ';' expected - 'set' found.
Link to overpass-turbo for this routine.
Update 2:
As per DaveF suggestions here is the modified the query. Now not able to make out how to set admin_level 4 names to admin_level 5.
[out:csv(::type,::id,admin_level,name,"name:en","country","admin_level_4_name")];
rel["name:en"="India"];
map_to_area->.a;
(
rel[admin_level=4](area.a)->.admin_level_4;
rel[admin_level=5](area.a)->.admin_level_5;
foreach.admin_level_5(
out center;
is_in->.admin_level_4_relation;
// not able to make out how to set level 4 name to level 5 relation
convert rel ::=::;
out;
);
);
Overpass turbo link for above query
asked
25 Oct '23, 08:32
Gagan
305●3●5●15
accept rate:
14%
It seems inconceivable you got to this stage by building the routine step by step. Start with the basics. Tip: you don't need to put every output into a named set. Try passing level 5 to the foreach
@Davef I have added the overpass-turbo error also. I suppose I am looping through the admin_level_5 only or is this not the correct way to loop?
Could you provide urls to an example of what your searching for? Both the district & state.
Here are URLs for India's states admin_level 4 and districts admin_level 5.
I think this query would help me. This is based on this example