[GIS] How to sum pixel values of a floating point raster in ArcMap

arcgis-10.1arcgis-desktoparcmaprasterstatistics

I have a floating point raster with values from 60 up to 95 (with decimals), it has 7077 pixels of 250x250m size.

Is there a way to sum all pixel values of this raster? For example, if the raster had 3 pixels with values of 60.20, 71.43 and 86.59, the sum would be 218.22.

I tried with zonal statistics and cell statistics, but it does not work. I am using ArcMap 10.1.

Best Answer

You can use a Python numpy array and a .sum() operation to sum all of the floating point values in the array. ArcGIS has an easy interface to convert raster data to a numpy array by using RasterToNumPyArray (arcpy)

# Import the arcpy site package
import arcpy, numpy

# Your input floating point raster
raster = r'C:\temp\floating_point_raster.tif'

# Convert the raster to a numpy array
array = arcpy.RasterToNumPyArray(raster, nodata_to_value = 0)

# Sum the array
array.sum()
Related Question