Measuring area of raster classes?
I would use the following workflow to calculate the area within the classes:
- Reclassify (Spatial Analyst) the kernel density output to whichever classes you are using. By default ArcGIS creates a continuous raster surface for the kernel density output, but reclassifies the legend (which is temporary). Using the reclassify tool will make this permanent.
- Open the reclassified kernel density attribute table and observe the "COUNT" field (Figure 1). This is the count of all the pixels in each class. For example, Class 1 (Value = 1) has a count of 620,063 pixels. Since my coordinate system is UTM, the units are in meters and the pixels are at 1m spatial resolution. Therefore, Class 1 is 620,063 m^2.
- To convert the count to other units such as hectares, add a new field in the attribute table.
- Calculate field (Figure 2)
- Logic check the results by highlighting a class (Figure 3)
Figure 1
Figure 2
Figure 3
If you want an arcpy solution:
import numpy as np #not sure how arcpy imports numpy
r = arcpy.RasterToNumPyArray('your raster name')
for val in np.unique(r):
area = np.sum(r == val) #multiply this by your pixel area
print 'value ', val, ' : ', area
alternatively you can write the values to a csv/text file.