[GIS] Classification to attribute

arcgis-desktopattribute-tableclassification

Using Esri Desktop Advanced 10.2.2 is it possible to create an attribute based on a classification method, i.e. Jenks? To elaborate – if you use the symbology tab in a layers properties, you can set a classification method that displays the class breaks, but I want to also do some statistical analysis based on those class breaks. Previously, I have done this by performing the classification using the layer properties and then using the class breaks to do a SQL and manually editing a attribute field with the class number. This works, but is labor intensive. Is there a progamatic way to do this?

Best Answer

You can calculate natural break values using the PySAL library, then Reclassify or use those values as you choose.

import arcpy, pysal
from pysal.esda.mapclassify import Natural_Breaks as nb
myArray = arcpy.RasterToNumPyArray(<PATH TO RASTER HERE>)
breaks = nb(myArray.ravel(),k=<NUMBER OF CLASSES HERE>,initial=20)
Related Question