Skip to content

Commit

Permalink
fix: clip square grid with AOI
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadh committed Mar 19, 2024
1 parent 1e64589 commit 0a3cc85
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fmtm_splitter/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a3cc85

Please sign in to comment.