4

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.

  • If you don't mind rounding to an integer you can do that and then just open the VAT (attribute table). If you need more precision, I might try creating a zone that encompasses the full extent and doing a "Zonal Sum" with Spatial Analyst. – jbchurchill Jul 16 '15 at 13:28
  • I haven't got ArcGIS to hand right now, but if you right click, select properties, and look under the general or source tab it might have a sum description, let me know if this doesn't help and I will look further. – Spatial Digger Jul 16 '15 at 13:29
  • I tried that but it only appears the max, min, mean and SD. – Karla Enher Jul 16 '15 at 13:47
8

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()
  • With the new change it perfectly works! Thank you! – Karla Enher Jul 16 '15 at 15:12
  • But I am getting return _RasterToNumPyArray(*args, **kwargs) MemoryError: even to 400MB raster. – SIslam Nov 18 '16 at 2:57
-2

A simple method is:

mean pixel value * total number of pixels

The source tab in layer properties has all the information you need for this calculation.

  • This approach assumes your raster has no nodata values so would vastly over estimate if your raster has many nodata cells. @Aaron has a much more robust solution. – Hornbydd Nov 14 '18 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.