Skip to content

Commit

Permalink
Fixes the area , from median area to obsolute area
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Dec 7, 2023
1 parent 53ba435 commit 9081721
Showing 1 changed file with 4 additions and 10 deletions.
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

0 comments on commit 9081721

Please sign in to comment.