How to sum the values of all cells in particular raster?

3999
12
05-29-2012 11:28 AM
Highlighted
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

How to sum the values of all cells in particular raster?

The cells of the raster shown in the screenshot below represents the volume of the rainfall, how to sum the values of all these cells?

Which command can sum up the values of all cells?

[ATTACH=CONFIG]14721[/ATTACH]


Thank you for the help,
Best
Jamal
Reply
0 Kudos
12 Replies
Highlighted
Regular Contributor III
Run Zonal Statistics as Table.  First you need to create a zone though.  We will use your rainfallvolume raster to do this.  Open the Raster Calculator and input Int("RainfallVolume" * 0).  This will return an integer raster of all zero's (constant value) that is the exact size and shape of the rainfall data.  Use this raster as the input zones using the Value field.  Use the rainfall raster as the Input Value Raster, also using the Value field.

-Eric
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Run Zonal Statistics as Table.  First you need to create a zone though.  We will use your rainfallvolume raster to do this.  Open the Raster Calculator and input Int("RainfallVolume" * 0).  This will return an integer raster of all zero's (constant value) that is the exact size and shape of the rainfall data.  Use this raster as the input zones using the Value field.  Use the rainfall raster as the Input Value Raster, also using the Value field.

-Eric


Thank you for the answer. This very helpful.

Then why the count of all cells of the rainfall raster doesn�??t equal the multiplication the number of rows and column?

[ATTACH=CONFIG]14729[/ATTACH], [ATTACH=CONFIG]14730[/ATTACH]
Reply
0 Kudos
Highlighted
Regular Contributor III
Jamal,

The zone we created only surrounds the real pixels.  It isn't including the NoData pixels in the count.  The input value raster is 897*563, which is 505,011 pixels.  The count field you got indicates there is only 343,809 pixels.  I ran this in the raster calculator - Con(IsNull("RainfallVolume"),1) which converts NoData to 1.  I checked the count and it is 161,202.  343,809 + 161,202 = 505,011.

Regards,
Eric
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Jamal,

The zone we created only surrounds the real pixels.  It isn't including the NoData pixels in the count.  The input value raster is 897*563, which is 505,011 pixels.  The count field you got indicates there is only 343,809 pixels.  I ran this in the raster calculator - Con(IsNull("RainfallVolume"),1) which converts NoData to 1.  I checked the count and it is 161,202.  343,809 + 161,202 = 505,011.

Regards,
Eric


Many thanks Eric.

Is there a command that calculates the total number of cells of raster?
Reply
0 Kudos
Highlighted
Regular Contributor III
Not out of the box.
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: stevelynch

These 2 GP tools can be used
GetRasterProperties using COLUMNCOUNT and ROWCOUNT will give you the size and
the output from ISNULL will indicate how many are NoData

and if you're using 10.x in Python you can convert the raster to NumPy array (arcpy.RasterToNumPyArray) and then work on the array

-Steve
Reply
0 Kudos
Highlighted
Regular Contributor III
Get Raster Properties tool doesn't give you the product of COLUMNCOUNT and ROWCOUNT.  We should probably just enhance that tool to provide TOTAL_PIXEL_COUNT.  It's still currently up to you to do the math, hence my comment "Not out of the box".
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Get Raster Properties tool doesn't give you the product of COLUMNCOUNT and ROWCOUNT.  We should probably just enhance that tool to provide TOTAL_PIXEL_COUNT.  It's still currently up to you to do the math, hence my comment "Not out of the box".


Sure, for particular application we need to have the total number of cells to proceed in doing the analysis.
Reply
0 Kudos
Highlighted
Regular Contributor III
Jamal,

What is the real requirement?  Do you need the count of all pixels, or just the ones with data?  These numbers can be very different as you have seen.  Why do you need the counts?  Please elaborate in detail.

Thanks,
Eric
Reply
0 Kudos