Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As best as I can tell this is a simple KNN analysis. The alternative "no distance matrix" component that the ESRI help explains seems quite undesirable. Basically they are using a K-means clustering with a region growing approach using random seeding. This seems very unstable and could return highly variable results. It seems like they are performing a bit of maneuvering to avoid some issues like disconnected regions so it may take some doing to exactly recreate their results. You can approximate the "spatially constrained" option in spdep. Here is a brief example of a distance analysis that will give you a starting point. Keep in mind that in order to assign "classes" you will need to set up some type of looping structure.</p> <pre><code>require(sp) require(spdep) data(meuse) coordinates(meuse) &lt;- ~x+y # Create distance matrix of specified range meuse.dist &lt;- dnearneigh(coordinates(meuse), 0.0001, 1000) # Coerce distance object to a list object with distances for each observation dist.list &lt;- nbdists(meuse.dist, coordinates(meuse)) # Create a new column with the distance to the nearest observation using lapply and unlist meuse@data &lt;- data.frame(meuse@data, NNDist=unlist(lapply(dist.list, FUN=function(x) min(x)))) # Plot results spplot(meuse, "NNDist", col.regions=colorRampPalette(c("blue","yellow","red"), interpolate="spline")(10) ) </code></pre> <p>You may want to also explore Hierarchical Clustering. However, for larger data sets, hclust needs a triangular distance matrix whereas dnearneigh does not. Here is an example using constrained hierarchical clustering.</p> <pre><code># SPATIALLY CONSTRAINED CLUSTERING require(sp) require(rioja) data(meuse) coordinates(meuse) &lt;- ~x+y cdat &lt;- data.frame(x=coordinates(meuse)[,1],y=coordinates(meuse)[,2]) rownames(cdat) &lt;- rownames(meuse@data) chc &lt;- chclust(dist(cdat), method="conslink") # KNN chc.n3 &lt;- cutree(chc, k=3) # DISTANCE chc.d200 &lt;- cutree(chc, h=200) meuse@data &lt;- data.frame(meuse@data, KNN=as.factor(chc.n3), DClust=chc.d200) opar &lt;- par par(mfcol=c(1,2)) cols &lt;- topo.colors(length(unique(meuse@data$KNN))) color &lt;- rep("xx", nrow(meuse@data)) for(i in 1:length(unique(meuse@data$KNN))) { v &lt;- unique(meuse@data$KNN)[i] color[(meuse@data$KNN == v)] &lt;- cols[i] } plot(meuse, col=color, pch=19, main="KNN Clustering") cols &lt;- topo.colors(length(unique(meuse@data$DClust))) color &lt;- rep("xx", nrow(meuse@data)) for(i in 1:length(unique(meuse@data$DClust))) { v &lt;- unique(meuse@data$DClust)[i] color[(meuse@data$DClust == v)] &lt;- cols[i] } plot(meuse, col=color, pch=19, main="Distance Clustering") par &lt;- opar </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload