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
Example block output

Classical

Geostatistical

Unlike classical clustering methods in machine learning, geostatistical clustering (a.k.a. domaining) methods consider both the values and the domain of the data.

GeoStatsTransforms.GHCType
GHC(k, λ; nmax=2000, kern=:epanechnikov, link=:ward, as=:cluster)

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 matrix
  • kern - Kernel function (:uniform, :triangular or :epanechnikov)
  • link - Linkage function (:single, :average, :complete, :ward or :ward_presquared)
  • as - Variable name used to store clustering results

References

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.
source
ctb = gtb |> GHC(20, 1.0)

ctb |> viewer
Example block output
GeoStatsTransforms.GSCType
GSC(k, m; σ=1.0, tol=1e-4, maxiter=10, weights=nothing, as=:cluster)

A transform for partitioning geospatial data into k clusters using Geostatistical Spectral Clustering (GSC).

Parameters

  • k - Desired number of clusters
  • m - Multiplicative factor for adjacent weights

Options

  • σ - Standard deviation for exponential model (default to 1.0)
  • tol - Tolerance of k-means algorithm (default to 1e-4)
  • maxiter - Maximum number of iterations (default to 10)
  • weights - Dictionary with weights for each attribute (default to nothing)
  • as - Variable name used to store clustering results

References

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.

source
ctb = gtb |> GSC(50, 2.0)

ctb |> viewer
Example block output
GeoStatsTransforms.SLICType
SLIC(k, m; tol=1e-4, maxiter=10, weights=nothing, as=:cluster)

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 clusters
  • m - Hyperparameter of SLIC model

Options

  • tol - Tolerance of k-means algorithm (default to 1e-4)
  • maxiter - Maximum number of iterations (default to 10)
  • weights - Dictionary with weights for each attribute (default to nothing)
  • as - Variable name used to store clustering results

References

source
ctb = gtb |> SLIC(50, 0.01)

ctb |> viewer
Example block output