Skip to content

Commit 9c12412

Browse files
committed
added option to buffer bbox_list obtained from AreaSplitters
1 parent e58a80f commit 9c12412

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

sentinelhub/areas.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,28 @@ def _make_split(self):
7575
"""
7676
raise NotImplementedError
7777

78-
def get_bbox_list(self, crs=None):
78+
def get_bbox_list(self, crs=None, buffer=None, reduce_bbox_sizes=None):
7979
"""Returns a list of bounding boxes that are the result of the split
8080
8181
:param crs: Coordinate reference system in which the bounding boxes should be returned. If None the CRS will
8282
be the default CRS of the splitter.
8383
:type crs: CRS or None
84+
:param buffer: A percentage of each BBox size increase. This will cause neighbouring bounding boxes to overlap.
85+
:type buffer: float or None
86+
:param reduce_bbox_sizes: If `True` it will reduce the sizes of bounding boxes so that they will tightly
87+
fit the given geometry in `shape_list`. This overrides the same parameter from constructor
88+
:type reduce_bbox_sizes: bool
8489
:return: List of bounding boxes
8590
:rtype: list(BBox)
8691
"""
87-
bbox_list = self._reduce_sizes(self.bbox_list) if self.reduce_bbox_sizes else self.bbox_list
92+
bbox_list = self.bbox_list
93+
if buffer:
94+
bbox_list = [bbox.buffer(buffer) for bbox in bbox_list]
95+
96+
if reduce_bbox_sizes is None:
97+
reduce_bbox_sizes = self.reduce_bbox_sizes
98+
if reduce_bbox_sizes:
99+
bbox_list = self._reduce_sizes(bbox_list)
88100

89101
if crs:
90102
return [bbox.transform(crs) for bbox in bbox_list]

sentinelhub/geometry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def buffer(self, buffer):
243243
""" Changes both BBox dimensions (width and height) by a percentage of size of each dimension. If number is
244244
negative, the size will decrease. Returns a new instance of BBox object.
245245
246-
:param buffer: A percentage
246+
:param buffer: A percentage of BBox size change
247247
:type buffer: float
248248
:return: A new bounding box of buffered size
249249
:rtype: BBox

tests/test_areas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_return_type(self):
4646
for test_case in self.test_cases:
4747
with self.subTest(msg='Test case {}'.format(test_case.name)):
4848
return_lists = [
49-
(test_case.splitter.get_bbox_list(), BBox),
49+
(test_case.splitter.get_bbox_list(buffer=0.2), BBox),
5050
(test_case.splitter.get_info_list(), dict),
5151
(test_case.splitter.get_geometry_list(), (shapely.geometry.Polygon, shapely.geometry.MultiPolygon))
5252
]

0 commit comments

Comments
 (0)