This is quite a simple question and I'm sure it's possible as I've seen it referenced in research articles (e.g. here, p.38). I have a raster with continuous values (0-1), and a vector dataset of a line. What I want as output is the 95th percentile of all cells intersecting the raster (the top 5 percentile is above this value).

So for example, if my raster is intersected by the line at 100 cells, I want the value of the 95th highest cell. Zonal statistics as table only seems to be able to output the median, mean, or maximum cell values. Is there any simple way to do this, in ArcGIS or arcpy?

  • Single line or multiple?
    – FelixIP
    Commented Jan 11, 2019 at 0:05

2 Answers 2


Not sure that they used a zonl analysis in the paper mentioned, as GPS point are more likely points. That being said, you can use the zonal histogram function the get the quantiles based on the frequency table. However, you will need to discretize your continuous values (example, multiply your [0-1] range by 1000 and roud it, so this is not an exact solution.

  • Thanks, this gives me an output I can work with. I'll try to come up with a way to automatically find the 95th percentile from this.
    – Maarten
    Commented Jan 10, 2019 at 15:15
  • This solved by problem although any tips to make my workflow simpler are appreciated. I forgot to mention that my line file contains multiple lines in the original. Currently doing this: 1. Iterate over each line, compute zonal histogram of each line(to avoid overlapping line cell problem) 2. Read each csv of zonal histogram as a list 3. For every list, multiply each value label by its frequency 4. Sum all those values * 0.95 5. Iterate over list again and find index of value that is equal or greater than value from step 4. As you can see, this is overtly complex, any help is welcome
    – Maarten
    Commented Jan 11, 2019 at 11:45

Try the following workflow:

  1. Convert your poly line to raster
  2. Run Spatial Analyst’s Sample
  3. Convert resulting table to numpy array
  4. Use numpy.percentile on the column of interest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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