sentinel-hub/sentinelhub-py

[BUG] BatchSplitter doesn't work with bbox, only with geometry

mlubej opened this issue · 0 comments

Describe the bug

The above happens if a batch request is defined with the bbox parameter and not the geometry parameter. This causes issues with the following code.

from sentinelhub import BatchSplitter
from matplotlib.patches import Patch

splitter = BatchSplitter(batch_request=batch_request, config=config)
splitter.get_bbox_list()

the error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/f7/wf5f4ngj0mxd5xrdjzqz7vyr0000gn/T/ipykernel_57279/4253228497.py in <module>
      2 from matplotlib.patches import Patch
      3 
----> 4 splitter = BatchSplitter(batch_request=batch_request, config=config)
      5 splitter.get_bbox_list()

~/.pyenv/versions/3.8.7/envs/am/lib/python3.8/site-packages/sentinelhub/areas.py in __init__(self, request_id, batch_request, config)
    714         self.batch_request = batch_request
    715 
--> 716         batch_geometry = batch_request.geometry
    717         super().__init__([batch_geometry.geometry], batch_geometry.crs)
    718 

~/.pyenv/versions/3.8.7/envs/am/lib/python3.8/site-packages/sentinelhub/sentinelhub_batch.py in geometry(self)
    648         _, geometry, crs = self._parse_bounds_payload()
    649         if geometry is None:
--> 650             raise ValueError('Geometry is not defined for this batch request')
    651         return Geometry(geometry, crs)
    652 

ValueError: Geometry is not defined for this batch request

The issue is in the assumption made in https://github.com/sentinel-hub/sentinelhub-py/blob/develop/sentinelhub/areas.py#L647

To Reproduce

Steps to reproduce the behavior:

  1. define request with bbox
  2. define batch request
  3. use batch splitter

Expected behavior

no crash

Environment

  • Python 3.8.7
  • latest develop of sentinelhub-py

Stack trace or screenshots

image

Desktop (please complete the following information):

  • macOS Monterey 12.6
  • VSCode