Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG : Fix -> Area filters on Prediction #6

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions predictor/vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def vectorize(
if not merged:
merged_polygons.append(polygon)

areas = [poly.area for poly in merged_polygons]
max_area, median_area = np.max(areas), np.median(areas)
# areas = [poly.area for poly in merged_polygons]
# max_area, median_area = np.max(areas), np.median(areas)
polygons_filtered = []
for multi_polygon in merged_polygons:
if multi_polygon.is_empty:
Expand All @@ -96,16 +96,10 @@ def vectorize(
# If it's a MultiPolygon, iterate through individual polygons
if multi_polygon.geom_type == "MultiPolygon":
for polygon in multi_polygon.geoms:
if (
polygon.area != max_area
and polygon.area / median_area > area_threshold
):
if polygon.area > area_threshold:
polygons_filtered.append(Polygon(polygon.exterior))
# If it's a single Polygon, directly append it
elif (
multi_polygon.area != max_area
and multi_polygon.area / median_area > area_threshold
):
elif multi_polygon.area > area_threshold:
polygons_filtered.append(Polygon(multi_polygon.exterior))

gs = gpd.GeoSeries(polygons_filtered, crs=kwargs["crs"]).simplify(tolerance)
Expand Down