All,
Normally I use the geo-processing tools to complete the following task but I thought I would give the raster functions ago as they appear to be a quicker and smarter way of doing thinks, but I failed at the first hurdle!
I have a DEM and I want to set all negative elevation values to NODATA, typically I would use the Set Null tool to achieve this.
So I started to create a raster function (see screen shot below) but I cannot work out how to complete this apparently simple task.
How do you complete the dialog to say "value < 0". I'm not understanding what the greyed out operation box is telling me? For example if one was to write this in python it would be:
outSetNull = SetNull("elevation", "elevation", "VALUE < 0")
Would someone post a screen shot of how to run the local function Set Null as a Raster Function?
Solved! Go to Solution.
All,
Thanks for your help and especially Neil Ayres as his solution is basically a whole lot easier (see below)! With a second set of eyes looking over my shoulder we cracked this frustrating problem. Probably like Dan Patterson I'm used to using the geo-processing tools or scripting it and I was looking for a way to include the criteria part of the set null tool in the raster function, in my case the "Value < 0".
The short answer is you can't, it's not geared up to accept expressions. I had actually explored the approach I'm about to reveal but dismissed it as me making some mistake but it turns out there is a bug in 10.4.1 which I will explain.
So you need to create a boolean grid, in my case where elevation is less than 0, this is essentially the result of the criteria, then you chain that into the set null tool.
So the first raster function is Less Than Equal as shown below:
The output of LessThanEqual function feeds into the Set Null function along with the DEM for what will be the values used under a FALSE condition.
So the final function chain is this:
Now the bug is that ArcMap does not display this "on the fly raster" correctly. The symbology defaults to stretch using standard deviation. This should work but it does not as it is saying the value range is 0 to 1 when in my case it should 1m to 360m. So changing stretch type to min-max the values still stay at 0 to 1 even though it is showing the correct values in the mini statistics panel in the stretch panel. I had to tick on edit high/low values and manually set the min and max values then the raster displayed correct with everything below zero set to NODATA.
DEM showing cells in the sea (Value < 0) as NODATA
Is your raster called elevation or dem???
and it would be "Value < 0"
Are you asking about the example python code? I just copied that out of the help file as a comparison to show when scripting you declare a criteria of "Value < 0". I cannot work out how to put that criteria in the raster function as shown in the image.
didn't see the image analyst window... if so, it sounds more convoluted than using the raster calculator or the tool. apparently it is a right-click thing Editing functions on a raster dataset—Help | ArcGIS for Desktop
assuming this is the help you are talking about
Dan,
I had drilled down to the page Local function—Help | ArcGIS for Desktop but it gives no examples of how to complete the Set Null tool, it just lists what is available. I can't work out how to complete the dialog because the equivalent geo-processing tool accepts a criteria (e.g. "Value < 0"), hence my question.
Duncan
and you toggle on the Spatial Analyst extension in the Customize Extensions menu?
The link I gave was for more generic operations which I think are the how too.
I suppose these have there place, but I still use a tool or program access to the tool through python... and cleanup when I am done.
I get the feeling that the raster functions are easier to implement in ArcGIS Pro as shown in this thread. Trying to use Con statement in Raster Function in Pro . I just had a quick look in 10.4.1 and it is far less straight forward as using the Raster Calculator or in Python. However, maybe Curtis Price has some suggestions?
See this example, I just added a Mask function. This a Dem with everything below 1600m changed to NoData
Hi Neil,
I like your method nice and simple and almost certainly the way I will set pixels to no data in the future!
But it does not resolve the approach I was taking so I won't mark it as correct, sorry!
The good news is I managed to solve it, so see my solution.
Duncan
All,
Thanks for your help and especially Neil Ayres as his solution is basically a whole lot easier (see below)! With a second set of eyes looking over my shoulder we cracked this frustrating problem. Probably like Dan Patterson I'm used to using the geo-processing tools or scripting it and I was looking for a way to include the criteria part of the set null tool in the raster function, in my case the "Value < 0".
The short answer is you can't, it's not geared up to accept expressions. I had actually explored the approach I'm about to reveal but dismissed it as me making some mistake but it turns out there is a bug in 10.4.1 which I will explain.
So you need to create a boolean grid, in my case where elevation is less than 0, this is essentially the result of the criteria, then you chain that into the set null tool.
So the first raster function is Less Than Equal as shown below:
The output of LessThanEqual function feeds into the Set Null function along with the DEM for what will be the values used under a FALSE condition.
So the final function chain is this:
Now the bug is that ArcMap does not display this "on the fly raster" correctly. The symbology defaults to stretch using standard deviation. This should work but it does not as it is saying the value range is 0 to 1 when in my case it should 1m to 360m. So changing stretch type to min-max the values still stay at 0 to 1 even though it is showing the correct values in the mini statistics panel in the stretch panel. I had to tick on edit high/low values and manually set the min and max values then the raster displayed correct with everything below zero set to NODATA.
DEM showing cells in the sea (Value < 0) as NODATA