5

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.

3
  • 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. Commented Jul 16, 2015 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. Commented Jul 16, 2015 at 13:29
  • I tried that but it only appears the max, min, mean and SD. Commented Jul 16, 2015 at 13:47

2 Answers 2

10

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

1
  • 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
    Commented Nov 14, 2018 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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