Skip to content

Commit

Permalink
#259 fix the Kmeans cluster filter
Browse files Browse the repository at this point in the history
  • Loading branch information
2320sharon committed Jun 4, 2024
1 parent 79bfb85 commit 7ffdf9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/coastseg/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def get_kmeans_clusters(input_rmse: np.array, rmse: list) -> tuple:
np.mean(np.array(rmse)[labels == 0]),
np.mean(np.array(rmse)[labels == 1]),
]
if scores[0]>scores[1]:
labels = 1-labels
return labels, scores


Expand Down
4 changes: 3 additions & 1 deletion src/coastseg/transects.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ def load_intersecting_transects(

# Create a list to store the GeoDataFrames
gdf_list = []

# Iterate over each transect file and select the transects that intersect with the rectangle
for transect_file in transect_files:
transects_name = os.path.splitext(transect_file)[0]
transect_path = os.path.join(transect_dir, transect_file)
if not os.path.exists(transect_path):
logger.warning("Transect file %s does not exist", transect_path)
continue
transects = gpd.read_file(transect_path, bbox=bbox)
# keep only those transects that intersect with the rectangle
transects = transects[transects.intersects(rectangle.unary_union)]
Expand Down

0 comments on commit 7ffdf9d

Please sign in to comment.