I wonder could someone advise me on how to get node information out of a Overpass query (using the Python Overpy library) result in json format.
I started with a query looking simply for the number of buildings within a polygon and this worked fine with the following code:
''' import overpy
buildings_in_polygon = api.get(overpass_query_element) '''
In this case overpass_query_element was as follows:
way(poly:"53.360596 -6.305466 53.360596 -6.289673 53.359222 -6.285553 53.356476 -6.282806 53.353729 -6.274567 53.350983 -6.274567 53.339996 -6.285553 53.338623 -6.289673 53.338623 -6.295166 53.339996 -6.299286 53.342743 -6.302032 53.34549 -6.310272 53.349609 -6.311646 53.355103 -6.311646 53.359222 -6.310959 53.360596 -6.308899 53.360596 -6.305466")["building"~"residential|house|terrace|detached|apartments"]; out; But now, I want to get details on the public parks (e.g. lat and lng and tags) in the same polygon, preferably in json format. Looking at Overpass turbo for some clues, I changed the query to be the following:
[out:json]; way(poly:"53.360596 -6.305466 53.360596 -6.289673 53.359222 -6.285553 53.356476 -6.282806 53.353729 -6.274567 53.350983 -6.274567 53.339996 -6.285553 53.338623 -6.289673 53.338623 -6.295166 53.339996 -6.299286 53.342743 -6.302032 53.34549 -6.310272 53.349609 -6.311646 53.355103 -6.311646 53.359222 -6.310959 53.360596 -6.308899 53.360596 -6.305466")["leisure"="park"]; out body;>; I get a list of 18 ways with their constituent nodes but can someone tell me, how do I access the data for the nodes and how to put it in json, in the way the data for a postbox node is returned from overpass turbo as below:
{ "type": "node", "id": 331566535, "lat": 51.6555684, "lon": 7.8635666, "tags": { "amenity": "post_box", "collection_times": "Mo-Fr 16:45, Sa 10:30", "operator": "Deutsche Post", "ref": "Dambergstraße 49, 59069 Hamm" } }, Is the issue that the Overpy library can only do counts and cannot return json?