Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have raster data that represents a probability distribution, i.e. each cell has a probability value (in my case the probability that an animal may be found in the cell), and all the cells add up to 100% (I know for certain the animal is within the extents of my raster). I want to be able to generate vector data for confidence values. For example, the 95% line/polygon denotes the boundary wherein I am 95% confident that I will find the animal.

Similarly, if I have a kernel density estimate, How do I generate the XX% line/polygon that borders the densest part of the raster containing XX% of the total population?

I am willing to use ArcGIS, or open-source software. If there isn't a tool to perform this for me, what is an algorithm I can implement?

share|improve this question
Mathematica solutions have recently appeared at mathematica.stackexchange.com/questions/20464. –  whuber Mar 5 '13 at 4:43
add comment

2 Answers

up vote 2 down vote accepted

Confidence is not an applicable concept, although it is superficially similar. The question sounds rather like you want to identify the smallest region having a total probability at least 95%. This region can be obtained (at least conceptually) by sorting all the probabilities and accumulating them from highest to lowest until the partial sum first equals or exceed 95%, then selecting the cells corresponding to the values that have been accumulated. This leads to a straightforward solution, as exemplified by this R (open source) example:

set.seed(17)                   # Seed a reproducible random sequence
nr <- 30                       # Number of rows                    
nc <- 50                       # Number of columns
# Create a zone raster for normalizing the probabilities.
zone <- raster(ncol=nc, nrow=nr)
zone[] <- 0
# Create a probability raster (for illustrating the algorithm later).
p <- raster(ncol=nc, nrow=nr)
p[] <- (1:(nc*nr) - 1/2) / (nc*nr) + rnorm(nc*nr, sd=0.5)
p <- abs(focal(p, ngb=5, run=mean))
z <- zonal(p, zone, stat='sum')
p <- p / z[[2]] # This normalizes p to sum to unity as required
# The algorithm begins here.
pvec <- sort(getValues(p), decreasing=TRUE) # The probabilities, sorted
d <- cumsum(pvec)                           # Cumulative probabilities
dpos <- d[d <= 0.95]                        # Position to stop
region <- p                                 # Initialize the output
region[p < pvec[length(dpos)]] <- NA        # Exclude the last 5% of the probability
plot(region)                                # Display the result

Here is the resulting image of the 95% probability region with the original probabilities shown in color: they sum to just over 95%, by construction, and eliminating even the smallest value will reduce the sum to less than 95%. The white area at the top includes the remaining 5% of the probability outside this region. The desired contour is the boundary between the white cells and the colored cells.


The same method will work on a KDE grid.

There is no straightforward ArcGIS solution for this problem.

share|improve this answer
Ha ha, superficial correctly describes my understanding of probability. Thanks so much for a) correctly interpreting my poorly worded question, and b) providing a clear answer. –  Regan Sarwas Feb 2 '12 at 17:12
add comment

In ArcGIS...

  • Spatial Statistics Tools > Reclass > Reclassify Tool
    • Create 2 reclassify methods:
    • OldValues = 0-94.99 | NewValues = 0
      OldValues = 95-100 | NewValues = 1

This will create a new raster with 2 values, 0 = outside confidence interval, 1 = inside 95% confidence interval.

  • Conversion Tools > From Raster > Raster to Polygon tool
    • Input = Reclassed Raster
      Field = Value

This will create a vector polygon with 2 FIDs, one with the shape of your 95% confidence interval and the other your remaining raster area. I would suggest exploring the simplify option to see what results would suit your needs better.

FYI, apply the same method to get the polygons for your Kernal Density estimates.

share|improve this answer
Perhaps I wasn't clear (I'm not very good with probability). To restate, the total of the values in all my cells is 1.0, so with a uniform distribution in a 100x100 grid, each cell would have a value of 1/10000. Now imagine the cell values vary from some slightly larger number near the center to values of zero near the edges (still totaling 1.0). If I start removing cells with the smallest values, eventually I will be left with a total of 0.95. How do I do this so I can reclassify as you have suggested. –  Regan Sarwas Feb 1 '12 at 23:02
Strange, fromy understanding of using rasters to display statistical representation of data, your probability value (cell value) would be anywhere from 0 to 100 (or in your case 0 to 1), and the distribution of these values (cell values) would represent a normal distribytion. –  Michael Markieta Feb 1 '12 at 23:19
If true, than we can reclassify the data using the method suggested above, albeit substitutig values of .9499 and .95 for 94.99 and 95 –  Michael Markieta Feb 1 '12 at 23:20
This solution does not reflect the grid described in the question. Think of the input grid as representing a discrete two-dimensional probability distribution rather than being a "statistical representation of data." In practical cases (medium to large grids, moderately well distributed animal range) most of the probabilities will be extremely small, far less than 95%, so the reclassification will merely wipe out all the information: everything turns to zero. –  whuber Feb 2 '12 at 2:11
Thanks for the clarification @whuber! –  Michael Markieta Feb 2 '12 at 2:13
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.