NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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's gravatar image

geographylover
11112
accept rate: 0%


permanent link

answered 29 Mar '21, 20:45

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

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, 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 '21, 22:18) DaveF

Follow this question

By Email:

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

By RSS:

Answers

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:

×689
×483
×129
×78

question asked: 29 Mar '21, 20:22

question was seen: 2,238 times

last updated: 29 Mar '21, 22:18

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum