I've been reading about algorithms for spatial clustering and it's easy to get lost since there are dozens of them. An idea that came to my mind is to use an a-spatial cluster algorithm on a dataset where the lat and long variables are also included as inputs of the model. This way, the algorithm uses the spatial proximity between observations as one additional co-variate in the clustering process.

Question: This idea sounds too obvious and simple to me and yet I haven't seen any book nor manual mentioning this approach, or at least explaining why it shouldn't be used. So I would like to pick your brains on this, what pros and mainly what cons you see in this approach ?

Clearly, this is an unorthodox approach and it's somewhat limited because it considers only euclidean distances and it would work better for spatial points or regular polygons on a regular lattice. Apart from that, I'd like to hear if there are any strong reasons not to use this approach. Any ideas?

Reproducible example below using mclust in R


# load housing dataset of Lucas county OH/USA
  house <- spTransform(house, CRS("+proj=longlat +datum=WGS84"))

enter image description here

# get only a sample of points for the sake of code speed 
  df <- data.frame(house)
  df$id <- 1:nrow(df)
  id_samples <- floor(runif(3000, min=1, max=nrow(df)))
  df <- subset(df, id %in% id_samples)

# get variables to input in the model into a matrix
  df <- df[ , c('long', 'lat', 'yrbuilt', 'avalue')] # get variables lat, long, when the house was built and its value
  df <- as.matrix(df)

# run Mclust model 
  d_clust <- Mclust(as.matrix(df), G=1:9)

# the optimal number of clusters is 8
  cat("model-based optimal number of clusters:", dim(d_clust$z)[2] , "\n")

# plot. The 1st chart on the 1st column shows how the clusters are spatially distributed
  plot(d_clust, what="classification")

enter image description here


Just a technicality (should be a comment but I lack reputation):

In any case this needs a coordinate reference system that gives you euclidean distances in your attribute space, for example UTM:

# specify original CRS:
proj4string(house) <- CRS("+proj=longlat +datum=WGS84")
# transform to new CRS (need to specify correct UTM zone):
house <- spTransform(house, CRS("+proj=utm +zone=50 ellps=WGS84"))

Conceptually, three things from the top of my head that may be relevant (?):

  1. how do you weight geographical distance against distances between attributes? E.g. how does 10 years difference in building age weight against 10 meter difference in x/y direction? Then again, the same problem exists for non-spatial attributes anyway.

  2. I am not certain about this, but maybe in some contexts, X and Y location shouldn't be seen as independent attributes. Say two buildings have identical position on X, but very different position on Y. Does the closeness in dimension X really mean anything? Moreover, if the Y values are very similar, it should make the similarity in X a lot more important, but that doesn't seem to be the case either. There are cases where X and Y can of course be used independently; E.g. if it is important how close you are to the equator, the latitude alone contains important information independent from the longitude.

  3. In many cases I think you would be interested not in the absolute location, but in some kind of relative location to other things. Depending on what the goal of the clustering is, instead of x and y you could include for example the distance to the (city-?) center or the distance to the nearest neighbour (both would solve 2.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.