diff --git a/fmtm_splitter/splitter.py b/fmtm_splitter/splitter.py index 18ede23..334b386 100755 --- a/fmtm_splitter/splitter.py +++ b/fmtm_splitter/splitter.py @@ -154,7 +154,10 @@ def splitBySquare( # noqa: N802 polygons = [] for x in cols[:-1]: for y in rows[:-1]: - polygons.append(box(x, y, x + width, y + length)) + grid_polygon = Polygon([(x, y), (x + width, y), (x + width, y + length), (x, y + length)]) + clipped_polygon = grid_polygon.intersection(self.aoi) + if not clipped_polygon.is_empty: + polygons.append(clipped_polygon) self.split_features = FeatureCollection([Feature(geometry=poly) for poly in polygons]) return self.split_features