Skip to content

Commit

Permalink
compute geo_folds based on centroids to be able to handle all geometr…
Browse files Browse the repository at this point in the history
…y types
  • Loading branch information
ptresson committed Apr 10, 2024
1 parent 76481cd commit 6b12c7a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/amaprs/utils/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,9 @@ def get_geo_folds(gdf,
print('please check that all geometry are valid')

X = []
for row in gdf.iterrows():
index, data = row
X.append([data.geometry.y, data.geometry.x])
# create centroids if geometry is different than points
for index, data in gdf.iterrows():
X.append([data.geometry.centroid.y, data.geometry.centroid.x])

X = np.array(X)
kmeans = KMeans(n_clusters=nfolds, random_state=seed).fit(X.astype('double'))
Expand Down

0 comments on commit 6b12c7a

Please sign in to comment.