I think you can do this by setting up a dissimilarity matrix between cells such that
diss((i,j),(k,l)) is large for non-neighbours, and is the difference between your cell values at
(i,j),(k,l) for neighbours. Then you feed the dissimilarity matrix into any clustering algorithm that takes a matrix -
pam or any of several in the Clustering Task View.
Then, for example,
hclust would proceed by starting with each cell in its own cluster, and merging the cells closest in the dissimilarity matrix on the first step. This would have to be two spatially adjacent cells, and all subsequent steps of the cluster algorithm would only ever add adjacent cells to clusters.
Note the difference between spatial distance and dissimilarity. Clustering works on the dissimilarity matrix, which in a conventional clustering problem is the (non-spatial) "distance" between two of the objects you are trying to cluster (eg age difference, blood pressure difference etc). What I'm trying to do here is defining that dissimilarity so that for non-adjacent cells the distance is large, whatever the value of the spatial variable you are trying to cluster.
I had a quick play to see if I could get this going but I'd done something wrong. Part of the problem is that if you have a NxM grid, you end up with an (NxM)x(NxM) dissimilarity matrix (or triangle of it) and I was probably getting a dimension wrong somewhere. Maybe later...