Hi everyone, I am working on a project where I am retrieving oil palm plantations from Benin using OSM and I am hoping to get the bounding box of each plantation. I was wondering if anyone knows how to extract the bounding box surrounding each plantation or any kind of longitude and latitude information. I could not figure out how to extract any relevant geometry information about type: area only nodes and ways. I included my code below I have so far and will clarify anything I need to. Thank You!
from OSMPythonTools.overpass import overpassQueryBuilder
from OSMPythonTools.nominatim import Nominatim
from OSMPythonTools.overpass import Overpass
nominatim = Nominatim() #How to call OpenStreetMaps Query Function
benin = nominatim.query('Benin') #Interested in Benin West Africa
oil_palm_trees = overpassQueryBuilder(area=benin.areaId(), elementType='area',includeGeometry = True ,selector=['"landuse"="orchard"',
'"trees" = "oil_palms"'], out='body')
overpass = Overpass()
oil_palm_plantation = overpass.query(oil_palm_trees)
oil_palm_plantation.elements() #show the elements returned from query
oil_palm_plantation.toJSON() #sbow the JSON Information, hoping to get the geometries
asked 29 Mar '21, 20:22

geographylover
11●1●1●2
accept rate: 0%
Hi, Dave thanks for the response. I tried doing this and the query worked but I still do not know how to extract the information. Sorry I am still a bit of a noob at this, so any help would be appreciated.
I don't use Python, but assume it's the same way you parse any data in XML. Try running the routine in Overpass Turbo & look under the data tag to see what's returned.