How do I extract a percentage of white pixels to dark pixels within the bounds of a feature class?

644
3
Jump to solution
04-03-2018 11:07 AM
CameronMcCarty
New Contributor

I have an image below that I have applied a threshold to. Along a traverse line I have several points I have created a buffer around, and now I want to run an analysis that extracts the percentage of white to dark and display it as a decimal in the attribute table line for each square.

Here is a sample of my image

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

zonal statistics will give you the data

http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/zonal-statistics.htm

except you will have to code/model an iteration for each polygon since your polygons overlap.

If the zone feature input has overlapping polygons, the zonal analysis will not be performed for each individual polygon. Since the feature input is converted to a raster, each location can only have one value.

An alternative method is to process the zonal statistics iteratively for each of the polygon zones and collate the results.

There is an old toolset which might work, or you could emulate, that handles the overlaps https://www.arcgis.com/home/item.html?id=b859b33c616a47d2b99b5e133942db02

View solution in original post

3 Replies
DanPatterson_Retired
MVP Emeritus

zonal statistics will give you the data

http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/zonal-statistics.htm

except you will have to code/model an iteration for each polygon since your polygons overlap.

If the zone feature input has overlapping polygons, the zonal analysis will not be performed for each individual polygon. Since the feature input is converted to a raster, each location can only have one value.

An alternative method is to process the zonal statistics iteratively for each of the polygon zones and collate the results.

There is an old toolset which might work, or you could emulate, that handles the overlaps https://www.arcgis.com/home/item.html?id=b859b33c616a47d2b99b5e133942db02

CameronMcCarty
New Contributor

Oh man! This works perfectly!... well almost... I only have one aspect that doesn't work. The old toolset you linked is incredible and is what I need, but.... it calculates the total number of pixels in the box (good), and the variety of pixel values in the box (good), but never says how many of each I have. It seems easy enough to add. Perhaps incorporating the zonal histogram tool? 

I just don't know how to add that to the toolbox file or the python command

0 Kudos
CameronMcCarty
New Contributor

Marking this correct. Since my only values are 0 and 1 I can multiply the mean by my total pixels to get the number of 1 values. 

It's not exactly right, but it's enough for me to get to where I need! For reference the zonal histogram may also be a good thing to use, but I didn't want to tweak the python program

0 Kudos