Skip to content

Commit

Permalink
deal with indexing in clean_crowns (#107)
Browse files Browse the repository at this point in the history
Stops issue with saving crowns to file
  • Loading branch information
PatBall1 authored Jun 14, 2023
1 parent 72077d6 commit 524a5be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions detectree2/models/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def clean_crowns(crowns: gpd.GeoDataFrame, iou_threshold=0.7, confidence=0.2):
print(str(index) + " / " + str(len(crowns)) + " cleaned")
# if there is not a crown interesects with the row (other than itself)
if crowns.intersects(shape(row.geometry)).sum() == 1:
crowns_out = pd.concat([crowns_out, row]) # retain it
crowns_out = pd.concat([crowns_out, row.to_frame().T], ignore_index=True) # retain it
else:
# Find those crowns that intersect with it
intersecting = crowns.loc[crowns.intersects(shape(row.geometry))]
Expand All @@ -382,7 +382,7 @@ def clean_crowns(crowns: gpd.GeoDataFrame, iou_threshold=0.7, confidence=0.2):
else:
match = match.drop("iou", axis=1)
# print(index)
crowns_out = pd.concat([crowns_out, match])
crowns_out = pd.concat([crowns_out, match], ignore_index=True)
# Convert pandas into back geopandas if it is not already
if not isinstance(crowns_out, gpd.GeoDataFrame):
crowns_out = gpd.GeoDataFrame(crowns_out, crs=crowns.crs)
Expand Down

0 comments on commit 524a5be

Please sign in to comment.