I want to set null all raster values that fall below the 75th percentile value. E.g. If you classify the raster by quantile method into 4 classes I want to be left with the top 25% percentile. For the raster shown below, 3.154941635 would be used in the set null expression.

I have attempted the following in the Calculate Value tool and a value of 0 is being returned. (source:https://community.esri.com/thread/162022)

enter image description here

enter image description here

  • Are you attempting to use the Calculate Value tool within Model Builder? If so, please, specify exactly how you are doing it by providing a print of your model. – umbe1987 Feb 25 at 15:16
  • Your model is just returining the 75% percentile of your input raster (wathever it is). You should use this value as the input to (e.g.) SetNull tool (I assume you have a Spatial Analyst license at this point). – umbe1987 Feb 25 at 15:34
  • I have multiple rasters where the 75% percentile value needs to be used as a cut off. I therefore need to build this part of the tool before I use this value in the set null tool and iterate the entire process. The calculate value tool is returning 0....not the value I am expecting. – FRMMO Feb 25 at 15:37
  • If I understand correctly, you need to calculate the 75% percentile of many rasters and for each set all the cells that are lower than this percentile to null, is that correct? If this is correct and you wanna stick to Model Builder rather than using Python scripts, you should do what I said and integrate the final model as an iterator submodel to another model (like explained here). Hope it helps. – umbe1987 Feb 25 at 15:44
  • Anyway, I think your main problem is that you have "attempted the following in the Calculate Value tool and a value of 0 is being returned.". What is your source raster? – umbe1987 Feb 25 at 15:49

For one raster, try to build your model builder like:

enter image description here

SetNull settings:

enter image description here

Expression for SetNull:

enter image description here

Beware that (reference):

Clicking the Verify button for an SQL query with an inline variable substitution in Query Builder, for tools such as Make Feature Layer, Select, and Select Layer By Attribute, will give you an invalid SQL query error, as the verification does not substitute the value of the inline variable when evaluating an expression. When the tool runs, the value of the inline variable is substituted in the expression and the results are created based on the substituted values.

Finally, as I said, you should use this model as a submodule used as an iterator to another model to run it against all your rasters (https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/integrating-model-within-a-model.htm#ESRI_SECTION1_FC4FA1B8DC0D418098AD21B774804821).

  • I have no issue with how to set a null value. My issue is calculating the 75% percentile value from the input raster data set. – FRMMO Feb 25 at 16:30
  • You said your attempt to running the Calculate Value led to 0 as result. I tried your same expression to calculate the 75% percentile against two different rasters and the result is correct. What is your source raster? Can you give more detail on the input raster you're using? – umbe1987 Feb 25 at 16:34
  • yes of course, thank you for your help. Floating point, 32 Bit, some rasters have up to 10 decimal places. 1 band WSG 1984. – FRMMO Feb 25 at 16:39
  • I bet the problem is that many decimal places. The tool is (lkely) rounding it so you always get 0. Have you tried changing the percentile value to see if the output is different than zero? If this is the problem, you could try multiplying the values of your raster by a certain amount (like times 1000000), and see if that brings you to a different result. You can do that using the Raster Calculator before everything in your model and give the multiplied raster to the Calculate Value tool as input. just a guess, might work... – umbe1987 Feb 25 at 16:58
  • Values of 0 are returned for percentiles up to the 85th. For the 86th percentile and above a value is returned. Negative values are returned for the 41st percentile and below. One test using the 90th percentile returns a value that's more likely to be the 35th. I have tried a range of raster data sets, integer and decimal. No success – FRMMO Feb 26 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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