cluster_spatial¶
cluster_spatial
¶
cluster_spatial(info: DataFrame, *, method: str = 'hdbscan', min_cluster_size: int = 3, eps_m: float = 300.0) -> DataFrame
Group stations into spatial zones by physical proximity.
Returns info with a cluster column (-1 = noise/unclustered).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
('hdbscan', 'dbscan')
|
HDBSCAN auto-selects density scales; DBSCAN uses a fixed |
"hdbscan"
|
min_cluster_size
|
int
|
Minimum stations to form a zone. |
3
|
eps_m
|
float
|
Neighbourhood radius in metres (DBSCAN only). |
300.0
|
See Also
cluster_spectral : Topological instead of proximity zones.
cluster_diurnal_profiles : Behavioural instead of spatial clusters.
Examples:
Two tight groups ~11 km apart resolve into two DBSCAN clusters:
>>> import pandas as pd
>>> info = pd.DataFrame({
... "station_id": list("abcdef"),
... "lat": [48.85, 48.8501, 48.8502, 48.95, 48.9501, 48.9502],
... "lon": [2.35, 2.3501, 2.3502, 2.45, 2.4501, 2.4502],
... })
>>> sorted(int(c) for c in cluster_spatial(info, method="dbscan", eps_m=100, min_cluster_size=3)["cluster"].unique())
[0, 1]