Cluster Espacial#
import geopandas as gpd
import matplotlib.pyplot as plt
import requests
gdf = gpd.read_file("https://github.com/algarciach/AnalisisGeoespacial/raw/main/Covid19_model/Data/covid19_municipios_antioquia.gpkg")
gdf.info()
<class 'geopandas.geodataframe.GeoDataFrame'>
RangeIndex: 125 entries, 0 to 124
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 codigo_municipio 125 non-null object
1 nombre_municipio 125 non-null object
2 codigo_subregion 125 non-null object
3 nombre_subregion 125 non-null object
4 area_municipio 125 non-null float64
5 altitud 125 non-null float64
6 temperatura 125 non-null float64
7 humedad_relativa 125 non-null float64
8 poblacion 125 non-null int64
9 urbanizacion 125 non-null float64
10 densidad 125 non-null float64
11 muertes_covid19 125 non-null int64
12 recuperados_covid19 125 non-null int64
13 cfr 125 non-null float64
14 geometry 125 non-null geometry
dtypes: float64(7), geometry(1), int64(3), object(4)
memory usage: 14.8+ KB
K-means#
Agrupamiento Espacial (Regionalización)#
var = ["altitud", "temperatura", "humedad_relativa", "urbanizacion", "densidad"]
from sklearn.preprocessing import StandardScaler
cat_std = StandardScaler().fit_transform(gdf[var])
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[4], line 1
----> 1 from sklearn.preprocessing import StandardScaler
2 cat_std = StandardScaler().fit_transform(gdf[var])
ModuleNotFoundError: No module named 'sklearn'
from scipy.cluster.hierarchy import linkage, dendrogram
Z = linkage(cat_std, method='ward', metric='euclidean')
plt.figure(figsize=(3, 3))
plt.xlabel('Sample index')
plt.ylabel('Cluster Distance')
dendrogram(Z, leaf_rotation=90, leaf_font_size=8, color_threshold=0.2*83, truncate_mode='lastp', p=5, show_leaf_counts=True, show_contracted=True)
plt.title('Dendrogram of Clusters')
plt.tight_layout()

from sklearn import cluster
k5cls = cluster.KMeans(n_clusters=5).fit(cat_std)
gdf['kmeans5'] = k5cls.labels_
f, ax = plt.subplots(1, 1, figsize=(10, 10))
gdf.plot(column='kmeans5', categorical=True, linewidth=0, legend=True, ax=ax)
ax.set_axis_off()

f, ax = plt.subplots()
gdf.boxplot(column='altitud', by='kmeans5', ax=ax)
<Axes: title={'center': 'altitud'}, xlabel='kmeans5'>

f, ax = plt.subplots()
gdf.boxplot(column='temperatura', by='kmeans5', ax=ax)
<Axes: title={'center': 'temperatura'}, xlabel='kmeans5'>

f, ax = plt.subplots()
gdf.boxplot(column='humedad_relativa', by='kmeans5', ax=ax)
<Axes: title={'center': 'humedad_relativa'}, xlabel='kmeans5'>

f, ax = plt.subplots()
gdf.boxplot(column='urbanizacion', by='kmeans5', ax=ax)
<Axes: title={'center': 'urbanizacion'}, xlabel='kmeans5'>

f, ax = plt.subplots()
gdf.boxplot(column='densidad', by='kmeans5', ax=ax)
<Axes: title={'center': 'densidad'}, xlabel='kmeans5'>

from pysal.lib import weights
w_k4 = weights.distance.KNN.from_dataframe(gdf, k=5)
f, axs = plt.subplots(figsize=(10, 10))
ax = gdf.plot(edgecolor='k', facecolor='w', ax=axs)
w_k4.plot(gdf, ax=axs, edge_kws=dict(color='r', linestyle=':', linewidth=1), node_kws=dict(marker=''),)
axs.set_axis_off()
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1484: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.loc[neighbors].centroid
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/libpysal/weights/weights.py:1496: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
centroids = gdf.centroid

from sklearn.metrics.cluster import silhouette_score
cl_k4_wk4 = cluster.AgglomerativeClustering(n_clusters=5, connectivity=w_k4.sparse).fit(cat_std)
print(silhouette_score(cat_std, cl_k4_wk4.labels_))
0.16510355129590978
w_d30 = weights.DistanceBand.from_dataframe(gdf, 30000, binary=False)
cl_d30 = cluster.AgglomerativeClustering(n_clusters=5, connectivity=w_d30.sparse).fit(cat_std)
print(silhouette_score(cat_std,cl_d30.labels_))
0.2917484846601373
/usr/local/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/scipy/sparse/_data.py:128: RuntimeWarning: divide by zero encountered in reciprocal
return self._with_data(data ** n)
gdf['knn5'] = cl_k4_wk4.labels_
f, ax = plt.subplots(1, figsize=(10, 10))
gdf.plot(column='knn5', categorical=True, linewidth=0, legend=True, ax=ax)
ax.set_axis_off()
