Help Filling no Data Raster using Calculate Raster (ERROR)

4079
6
04-09-2016 08:11 AM
BadWolf
New Contributor III

Dear all,

I'm trying to replace no data values within a raster, using "Calculate Raster" tool, but I'm getting an error that I cannot solve.


Here I attach what I am doing, and the error result given.

Error:

help2.png

Can someone give me a hint on what I am doing wrong?

Thank you

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

What version of arcmap?  The error message is common in some environments

41859 - ERROR 000539: Error running expression: rcexec()

In any event, you might be advised to go an alternate route with complex functions

A quick tour of using Map Algebra—ArcGIS Help | ArcGIS for Desktop

do this in the python window and do the focalstats first, then use it in the con statement, then save to disk.  There are example,in the help...just doesn't have that cool interface that the raster calculator does, but a lot easier to save your code snippets to a file for further use and documentation

0 Kudos
BadWolf
New Contributor III

Hi Dan, how are you doing?

Well, I'm using Arcmap 10.1. I must inform you that my knowledge in any kind of programming is equal to zero. I've tried to to Focalstatistics first but I think I will need some kind of syntax code before apply that function.. Have a look at the picturehelp3.png

Any help would be appreciated. Thanks

0 Kudos
DanPatterson_Retired
MVP Emeritus

Smokin!! a convert to the code... this is where your help file skills will need to get a workout

Focal Statistics—Help | ArcGIS for Desktop

What did you miss? (assuming not just within arcmap's python ide.

Check out the code snippet.  Now that snippet can be done line by line in interactive mode or you could use a python IDE and create a script and edit it.  Assuming you are doing this line-by-line (interactive mode), you need to do some imports, specify a file location and get a result.  You chose a situation where there a more lines than you probably want to type, so just copy, paste, modify from the help files and you will be done.  I estimate it would take you no longer than 2 minutes to copy-paste-modify the code from the help topic line-by line to get a result.  If you dare to go to a whole script, then it would take the same time...but you could reuse it if it didn't work the first time or wished to do it on other datasets.

So back to your immediate problem, let's do it manually using just the tools in ArcToolbox

So when you have the first two rasters created... fs_ras and null_ras ... you are ready to use them in the con tool.  You will then have your answer just use the logic you applied in your command line equation

"if the input raster is null at a location, use the focal mean of a 5x5 moving window to supply the value...otherwise just use the original value"

If you want to see what it looks like in a code snippet.. go to the Results Window and copy away  Using the Results window—Help | ArcGIS for Desktop

I blogged about this stuff a while ago ( "You are not allowed to use Modelbuilder": When Instructors need to get smarter  ) and there are others on my Blog The ...py... links there is a whole load of stuff there... so I don't forget

BadWolf
New Contributor III

Dear Dan,

Damn!! That's an answer! I want to truly thank you for one so explained answer that you gave me!

I am now struggling to do this task with using tools in Arc Toolbox, but as soon as I get this done I will try to do a code that I could apply to other datasets that I have!

Well, regarding this problem I will require more help from you (even though you were so detailed in your post!!).

I was able to create fs_ras and null_ras. These two tasks were successfully performed. The problem that I am getting is from using CON tool. Here is my input:

help1.png

The error that I am getting:

help2.png

Thanks one more time for your time! You really are a ArcGis bible!

Regards

0 Kudos
BadWolf
New Contributor III

I'm sorry, I have made a mistake over there. But I am getting the same error again.

I have now placed "VALUE" = 1.

But the error is exactly the same...

0 Kudos
DanPatterson_Retired
MVP Emeritus

now your expression is optional, so your IsNull raster is your conditional raster where 1 is true and 0 is false, so you don't need and optional query your fs_ras is the raster it should use if there are null values and the false raster is the original raster. 

Now the crux is the error messages.  Did you explicitly set your environments tab on the bottom center-ish of the dialog (anticipating a .... noooo) if not, do so, set the extents the cell size and the snap raster... of course you should have done this for the two previously created rasters... always set everything in the tool, don't rely on global settings.

The folder, is one that exists? and for testing I use variants X as a filename, since X, X1, X2 etc  since you aren't specifying a file extension (like tif), it will create an esri grid. 

The old error list is still useful ArcGIS Help (10.2, 10.2.1, and 10.2.2)  and if you go through the error numbers, it doesn't like something about your folder and or filename for the output grid... so have a check, try without the conditional statement.  (if you ever have to use the SQL dialog...type little to nothing and let the dialog build it for you)

That's all I can think of now.