Hello!
I have the following query which returns every place=village in South Tyrol:
[out:csv(name,"name:de","name:it","municipality","municipality:it",::lat,::lon;true;";")]; {{geocodeArea:"South Tyrol"}}; node[place~"village"](area); out body;
How can i get the name of the municipality the nodes are in?
For example: the village “Lengstein” (Node: Lengstein - Longostagno (1435595862) | OpenStreetMap ) is in the municipality “Ritten” (Relation: Ritten - Renon (47233) | OpenStreetMap ) which is admin_level 8.
I would like to get the name of the municipality where the node (place=village) is in.
Is this possible?
Thank you for your time and responses.
Have a great day!
Lorenz
aTarom
(aTarom)
May 8, 2024, 4:19pm
2
I’m not an expert, I’m playing with something like this , it seems to work but it’s better to wait for more opinions from those who really know about it
[out:csv(municipality_name,village_name; true; ";")];
area["ISO3166-2"="IT-BZ"];
node[place=village](area)->.villages;
foreach .villages -> .village (
.village;
is_in;
area._[admin_level=8]->.municipality;
make name_info
village_name = village.set(t["name"]),
municipality_name = municipality.set(t["name"]);
out;
);
Well that worked quite well, thanks!
However, I am not able to retrieve latitude and longitude information. This is what I tried:
[out:csv(municipality_name,village_name,village_lat,vlilage_lon; true; ";")];
area["ISO3166-2"="IT-BZ"];
node[place=village](area)->.villages;
foreach .villages -> .village (
.village;
is_in;
area._[admin_level=8]->.municipality;
make name_info
village_name = village.set(t["name"]),
village_lat = village.set(t["lat"]),
village_lon = village.set(t["lon"]),
municipality_name = municipality.set(t["name"]);
out;
and this is the result
municipality_name;village_name;village_lat;vlilage_lon
Stilfs - Stelvio;Trafoi;;
Stilfs - Stelvio;Sulden - Solda;;
Martell - Martello;Thal;;
Thanks a lot!
aTarom
(aTarom)
May 9, 2024, 12:46pm
4
Test this
[out:csv(municipality_name,village_name,village_lat,village_lon; true; ";")];
area["ISO3166-2"="IT-BZ"];
node[place=village](area)->.villages;
foreach .villages -> .village (
.village;
is_in;
area._[admin_level=8]->.municipality;
make name_info
village_name = village.set(t["name"]),
village_lat = village.set(lat()),
village_lon = village.set(lon()),
municipality_name = municipality.set(t["name"]);
out;
That worked how i wanted it to! Thanks a lot!!