Raster counts within polygons

4488
4
10-23-2013 11:50 AM
DanJensen1
New Contributor
Greetings,

I am trying to retrace some steps.  I was working experimentally and discounted the results and then after further analysis a few weeks later it was something that was useful.  I need to remember what the procedure was, or find another way to get the same answer.

Using ArcGIS 10.1

I have a raster layer with a given hydrology values in cm
I have a polygon layer with tree canopy classifications (1 for areas with tree canopy cover, 0 for polygons with no canopy cover)

I want to get pixel counts for the entire polygon layer for so that I know for each unique hydrology value what the counts of canopy and no canopy pixels are.  The final goal is to build a stacked histogram in excel to show the proportion of canopy and non canopy pixels at various hydrology levels.

I think I may have used zonal statistics in some manner, but I would appreciate any opinions.
Reply
0 Kudos
4 Replies
DanPatterson_Retired
MVP Esteemed Contributor
Did you give Zonal Statistics as Table a shot?
Reply
0 Kudos
DanJensen1
New Contributor
I have tried it and did use it for other parts of this analysis. 

Maybe I used it wrong, but I have polygon id numbers with a canopy classification, a count of pixels within that polygon, and then the min max mean etc of the raster values (I think that is what I am seeing).

What I want is the count of each unique hydrology value (which I have when I created the attribute table for the entire raster) broken down into the two tree canopy cover classes.

Did you give Zonal Statistics as Table a shot?
Reply
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor
Reply
0 Kudos
XanderBakker
Esri Esteemed Contributor
Hi Dan (and Dan),

Both Combine and Zonal Statistics (as table) will get you there. With the Combine option you can convert the result to Excel and make a pivot table.

I think the easiest way is to use the "Zonal Statistics as Table (Spatial Analyst)" as Dan first suggested.

You will have to use your hydrology raster as dataset that defines the zones and your canopy polygons (converted from polygons to raster) as your value raster. The result will give you all the statistics you need:

The COUNT will give you the area of each zone (if you multiply it be cell size)
The SUM will give you the number of pixels with canopy per zone
MEAN * 100 (or SUM / COUNT * 100) will give you the percentage of canopy per hydrology value


Some considerations:
If the zone input is a raster dataset (which it is), it must have an attribute table. This means it has to be of type Integer (cannot be Float). The attribute table is usually created automatically for integer rasters, but may not be under certain circumstances. You can use "Build Raster Attribute Table" to create one.

You can also Reclassify your hydrology values into meaningful classes and use those classes as zones.

Kind regards,

Xander
Reply
0 Kudos