I’m tring to get bbox for polygon I have . The polygons are originaly in geodataframe and I change it into the sentinelhub geometry object.
The problem is that when I try to get the bbox for that polygon. I get error:
AttributeError: ‘Polygon’ object has no attribute ‘total_bounds’
This is how I have tried to do this:
#function to get the bbox- coordinates, bbox and size: def get_bbox_from_shape(shape,resolution): minx, miny, maxx, maxy = shape.geometry.total_bounds bbox_coords_wgs84=[minx, miny, maxx, maxy] bbox = BBox(bbox=bbox_coords_wgs84, crs=CRS.WGS84) bbox_size = bbox_to_dimensions(bbox, resolution=resolution) return bbox_size,bbox,bbox_coords_wgs84 #get the bbox for each for name,shape in zip(shapes['name'],shapes['geometry']): shape=Geometry(shape,CRS.WGS84) bbox_size,bbox,bbox_coords_wgs84=get_bbox_from_shape(shape,10)
and that returns the attribute error.
I have used the Geoemtry in the past in order to get it as the correct object needed, so I have no idea why it doesn’t give me the bbox of the plot polygon.
My end goal is to be able to get bbox for each polygon in my geodataframe.