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, 20:22

geographylover's gravatar image

accept rate: 0%

permanent link

answered 29 Mar, 20:45

DaveF's gravatar image

accept rate: 6%

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.

(29 Mar, 21:09) geographylover

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.

(29 Mar, 22:18) DaveF
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 29 Mar, 20:22

question was seen: 88 times

last updated: 29 Mar, 22:18

powered by OSQA