2 Replies Latest reply on Jan 4, 2011 4:42 PM by jevans02

    fuzzy c-means cluster analysis

    ccabanero
      Hello,

      Does ArcGIS Desktop 10 with Geostatistical Analyst perform fuzzy c-means cluster analysis?  I am currently working with a procedure that requires I export tables to the R environment to do this. Would be nice if I can stay inside ArcGIS.

      Thank you,
      Clint
        • Re: fuzzy c-means cluster analysis
          lrosenshein-esristaff
          Hi Clint,

          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!

          Lauren Rosenshein
          Geoprocessing Product Engineer
          • Re: fuzzy c-means cluster analysis
            jevans02
            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

            # C-MEAN'S
            sclust <- cmeans(shape@data[,2:ncol(shape@data)], nc, iter.max=100, method="cmeans",
                                    weights=1, dist="euclidean")

            # 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]),])
               writePointsShape(shape, paste(outshape))

            #### END ####