Select to view content in your preferred language

Calculate Percentage of cells with a certain value.

5619
6
05-20-2011 10:33 AM
KylePurdon
Emerging Contributor
I have a raster of values either 1 or 0. I want to calculate the percentage of cells that are value=1. Any ideas?

(I know how to do this converting to a polygon and things like that, but would like a simpler method)

Also, I am doing this to implement into a model (modelbuilder) so please keep those limitations in mind.

Thanks!
0 Kudos
6 Replies
TimothyHales
Esri Notable Contributor
You will need to build a raster attribute table for the raster and then use the Summary Statistics tool.  Note that
you cannot build a raster attribute table for a raster dataset that is a pixel type of 32-bit floating point.  For this type of data you will need convert it to another pixel type such as in integer by using the integer tool.
0 Kudos
KylePurdon
Emerging Contributor
Thanks. However, I now have two fields (Either value of 1 or 0). Now how would I figure out what percentage of all cells are value=1. This is not a standard summary statistic. I know I could just do this after the fact but the goal is to make this tool a "one stop shop" outputting a table with the percentage value.
0 Kudos
KylePurdon
Emerging Contributor
Bill,

I am using Arc10 and have access to any license level. (Currently on ArcInfo).
0 Kudos
KylePurdon
Emerging Contributor
All, I got it to work. Thanks for all the help! Below is my final solution for future use:


  • Input Lines and a Boundary

  • Calculate Point Density

  • Create Raster where point density >1 =1 else =0.

  • Create a "Zone Raster" with a mask/extent of the Boundary (Entire Raster is the Zone)

  • Used the "Zonal Statistics as Table" tool to calculate a mean. (Eg. The % of Cells = 1)


I used this to figure out what cell size would result in at least 50% of cells in a raster containing at least 1 point from the lines where interpolating.
Luke_Pinner
MVP Regular Contributor
A simpler method (in Model Builder/Toolbox) would be to use the GetRasterProperties_management tool and specify MEAN as the property to return.
0 Kudos
KylePurdon
Emerging Contributor
A simpler method (in Model Builder/Toolbox) would be to use the GetRasterProperties_management tool and specify MEAN as the property to return.


I like this method. Is there now a way to export these values to a table. In my tool I calculate the Percentage (Mean) for 3 different cell sizes so there are 3 output mean values. If I could create a .dbf with the cell size in one column and the output mean value in another that would be perfect.

Thanks!
Kyle
0 Kudos