Is there a library available in Python 3.6 using which I could convert a GeoJSON object (geometry) into a bounding box object?
Actually I am calling a WMS layer from GeoServer and I want to set the bounds of the map to the bounding box of the requested polygon (WMS layer) so the only method I could figure out to get bounds of an individual polygon from geometry is to get the geometry of the polygon using a getfeatureInfo request of WMS service and then converting that geojson to bounding box at the backend.
If there is any other method that I could do to get the bbox of an individual polygon from geoserver using WMS service then please suggest it?
Best Answer
You can probably use the
geojson
package to handle the JSON parsing, then finding the min/max corners of the bounding box is something like:which gives
(-120.43 -20.28, 23.194 57.322)
as a result.