if (FALSE) {
query <- opq ("hampi india") |>
add_osm_feature (key = "historic", value = "ruins")
# Then extract data from 'Overpass' API and save to local file:
osmdata_xml (query, filename = "hampi.osm")
}
# Complex query as a string (not possible with regular osmdata functions)
q <- '[out:xml][timeout:50];
area[name="Països Catalans"][boundary=political]->.boundaryarea;
rel(area.boundaryarea)[admin_level=8][boundary=administrative];
map_to_area -> .all_level_8_areas;
( nwr(area.boundaryarea)[amenity=townhall]; >; );
is_in;
area._[admin_level=8][boundary=administrative] -> .level_8_areas_with_townhall;
(.all_level_8_areas; - .level_8_areas_with_townhall;);
rel(pivot);
out tags;'
if (FALSE) {
no_townhall <- osmdata_xml (q)
no_townhall
}
Run the code above in your browser using DataLab