Suppose I have a 1-band image that represents a species' predicted density and distribution. I'd like to be able to spatially define regions based on density. For instance I'd like to extract pixels that represent the top 10% of of the population. That is, identify the largest valued pixels that when summed are 10% of the total sum of all pixels. Or top 20%, top 30% and so on.
I don't know if this is the best way but in my mind I see the workflow as the following possibility: 1) convert image to array, 2) sort those values from min to max and calculate a cumulative sum, 4) convert back to an image and divide by the maximum value...now any pixel value greater than .9 represents a pixel in the top 10%.
This is the script I've been playing with.