Skip to content
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
7 changes: 3 additions & 4 deletions neatnet/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def get_artifacts(
polys["isoareal_index"] = shape.isoareal_quotient(polys.geometry)
polys["isoperimetric_quotient"] = shape.isoperimetric_quotient(polys.geometry)

is_artifact = polys["is_artifact"]
area = polys["area_sqm"]
isoareal = polys["isoareal_index"]
isoperimetric = polys["isoperimetric_quotient"]
Expand All @@ -365,7 +364,7 @@ def _all_any(group):
while True:
# count number of artifacts to break while loop
# when no new artifacts are added
artifact_count_before = sum(is_artifact)
artifact_count_before = sum(polys["is_artifact"])

# polygons that are enclosed by artifacts (at this moment) and
# that are touching artifacts (at this moment)
Expand Down Expand Up @@ -397,11 +396,11 @@ def _all_any(group):
cond_metric = isoperimetric > isoperimetric_threshold_circles_touching
polys.loc[cond_geom & cond_area & cond_metric, "is_artifact"] = True

artifact_count_after = sum(is_artifact)
artifact_count_after = sum(polys["is_artifact"])
if artifact_count_after == artifact_count_before:
break

artifacts = polys[is_artifact][["geometry"]].reset_index(drop=True)
artifacts = polys[polys["is_artifact"]][["geometry"]].reset_index(drop=True)
artifacts["id"] = artifacts.index

if exclusion_mask is not None:
Expand Down