I am trying to count the number of buildings within a series of polygons using the Overpass API in Python.
I have created a list of strings which contain the co-ordinates of the polygons and I iterate through them passing the string to a separate function to perform the count. In the called function, I am trying to create the query using the polygon string but I am not getting anything meaningful back. Eventually, I would like to get the co-ordinates of each building and the total number of buildings in the polygon but if I could even get the count that would be great.
An example of one of the polygon strings is
poly:"-6.199206 53.615774 -6.200352 53.615451 -6.200937 53.615362 -6.201668 53.616131 -6.201761 53.616235 -6.199634 53.616626 -6.199206 53.615774" My code is as follows:
def count_buildings(poly): api = overpy.Overpass() query_string = 'node(' + poly +')["building"];(._;>;); out;' # print(query_string) result = api.query(query_string) print(result) return len(result.nodes) 
