This content has been marked as final. Show 2 replies
This is a great question! Actually, we've got a great sample script that shows using R from inside of ArcGIS to do cluster analysis! The sample script has several options for the cluster method, including cmeans, which may be just what you're looking for! :) Even if it isn't the same method that you are currently using, the sample shows the use of python scripting within ArcGIS to connect to R. It may be a useful template for you moving forward so that you can avoid jumping in and out of ArcGIS and R.
Additionally, we are currently working on an implementation of K-Means ++ Clustering, with optional space/time constraints. We're calling it Group Similar Features, and it will be in the Spatial Statistics toolbox in ArcGIS 10.1. I know that 10.1 is still a ways off, but we're really excited about it and hopefully you will find it valuable in the future.
Hope this helps!
Geoprocessing Product Engineer
Here is an R script for performing fuzzy C-Means clustering. It accepts a point shapefile and assumes that the variables that you want to use for the analysis are in sequential columns. If you want to cluster polygons just change the sp class read/write functions to "readShapePoly" and "writePolyShape".
#### START ####
if (!require(maptools)) stop("maptools PACKAGE MISSING")
if (!require(e1071)) stop("e1071 PACKAGE MISSING")
inshape = "C:/ANALYSIS/points" # NAME OF POINT SHAPEFILE
outshape = "C:/ANALYSIS/cmeans_points" # NAME OF CLUSTERED SHAPEFILE
ID = "FID" # UNIQUE ID IN POINT SHAPEFILE
# READ POINT SHAPEFILE AS SP CLASS OBJECT
shape = readShapePoints(paste(inshape), proj4string=CRS(as.character(NA)), verbose=FALSE)
## FUZZY C-MEAN'S CLUSTERING ##
nc=4 # NUMBER OF CLUSTERS
sclust <- cmeans(shape@data[,2:ncol(shape@data)], nc, iter.max=100, method="cmeans",
# CLUSTER RESULTS WITH CLASSES AND PROBS FOR EACH CLASS
Zi <- as.data.frame(cbind(shape@data[,ID], sclust$cluster, sclust$membership))
names(Zi) <- c("FID", "CLASS", "p1", "p2", "p3", "p4")
# JOIN CLUSTER RESULTS TO SHAPEFILE AND WRITE OUT NEW SHAPEFILE
shape@data = data.frame(shape@data, Zi[match(shape@data[,ID], Zi[,ID]),])
#### END ####