Clustering
Overview
We provide various geostatistical clustering methods to divide geospatial data into regions with homogeneous features. These methods can consider the values
of the geotable (the classical approach), or both the values
and the domain
(the geostatistical approach).
Consider the following geotable for illustration purposes:
gtb = georef((z=[10sin(i/10) + j for i in 1:4:100, j in 1:4:100],))
gtb |> viewer

Classical
TableTransforms.KMedoids
— TypeKMedoids(k; tol=1e-4, maxiter=10, weights=nothing, rng=Random.default_rng())
Assign labels to rows of table using the k
-medoids algorithm.
The iterative algorithm is interrupted if the relative change on the average distance to medoids is smaller than a tolerance tol
or if the number of iterations exceeds the maximum number of iterations maxiter
.
Optionally, specify a dictionary of weights
for each column to affect the underlying table distance from TableDistances.jl, and a random number generator rng
to obtain reproducible results.
Examples
KMedoids(3)
KMedoids(4, maxiter=20)
KMedoids(5, weights=Dict(:col1 => 1.0, :col2 => 2.0))
References
Kaufman, L. & Rousseeuw, P. J. 1990. Partitioning Around Medoids (Program PAM)
Kaufman, L. & Rousseeuw, P. J. 1991. Finding Groups in Data: An Introduction to Cluster Analysis
ctb = gtb |> KMedoids(5)
ctb |> viewer

Geostatistical
GeoStatsTransforms.GHC
— TypeGHC(k, λ; nmax=2000, kern=:epanechnikov, link=:ward)
A transform for partitioning geospatial data into k
clusters according to a range λ
using Geostatistical Hierarchical Clustering (GHC). The larger the range the more connected are nearby samples.
Parameters
k
- Approximate number of clustersλ
- Approximate range of kernel function in length units
Options
nmax
- Maximum number of observations to use in dissimilarity matrixkern
- Kernel function (:uniform
,:triangular
or:epanechnikov
)link
- Linkage function (:single
,:average
,:complete
,:ward
or:ward_presquared
)
References
- Fouedjio, F. 2016. A hierarchical clustering method for multivariate geostatistical data
Notes
- The range parameter controls the sparsity pattern of the pairwise distances, which can greatly affect the computational performance of the GHC algorithm. We recommend choosing a range that is small enough to connect nearby samples. For example, clustering data over a 100x100 Cartesian grid with unit spacing is possible with
λ=1.0
orλ=2.0
but the problem starts to become computationally unfeasible aroundλ=10.0
due to the density of points.
ctb = gtb |> GHC(5, 1.0)
ctb |> viewer

GeoStatsTransforms.GSC
— TypeGSC(k, m; σ=1.0, tol=1e-4, maxiter=10, weights=nothing)
A transform for partitioning geospatial data into k
clusters using Geostatistical Spectral Clustering (GSC).
Parameters
k
- Desired number of clustersm
- Multiplicative factor for adjacent weights
Options
σ
- Standard deviation for exponential model (default to1.0
)tol
- Tolerance of k-means algorithm (default to1e-4
)maxiter
- Maximum number of iterations (default to10
)weights
- Dictionary with weights for each attribute (default tonothing
)
References
- Romary et al. 2015. Unsupervised classification of multivariate geostatistical data: Two algorithms
Notes
- The algorithm implemented here is slightly different than the algorithm
described in Romary et al. 2015. Instead of setting Wᵢⱼ = 0 when i <-/-> j, we simply magnify the weight by a multiplicative factor Wᵢⱼ *= m when i <–> j. This leads to dense matrices but also better results in practice.
ctb = gtb |> GSC(5, 2.0)
ctb |> viewer

GeoStatsTransforms.SLIC
— TypeSLIC(k, m; tol=1e-4, maxiter=10, weights=nothing)
A transform for clustering geospatial data into approximately k
clusters using Simple Linear Iterative Clustering (SLIC).
The transform produces clusters of samples that are spatially connected based on a distance dₛ
and that, at the same time, are similar in terms of vars
with distance dᵥ
. The tradeoff is controlled with a hyperparameter m
in an additive model dₜ = √(dᵥ² + m²(dₛ/s)²)
.
Parameters
k
- Approximate number of clustersm
- Hyperparameter of SLIC model
Options
tol
- Tolerance of k-means algorithm (default to1e-4
)maxiter
- Maximum number of iterations (default to10
)weights
- Dictionary with weights for each attribute (default tonothing
)
References
- Achanta et al. 2011. SLIC superpixels compared to state-of-the-art superpixel methods
ctb = gtb |> SLIC(5, 0.01)
ctb |> viewer
