Geodatabases and raster calculator?

3256
6
05-31-2013 04:25 PM
JacobGjesdahl
New Contributor
Hi, I had a model set up to work correctly but slow and someone suggested I change it to geodatabase files to make it go faster.  Now I'm facing the problem that lots of things no longer work.  The one in particular that I can't figure out on my own is that the raster calculator just makes a big block equal to 1 when it should only be doing a few areas (this worked fine before making it a geodatabase).  This is my expression:

Con( "%noview_value%" == 1 &
    ((("%beview_value%" == 0) & ("%hhview_value%" == 0)) |
    (("%beview_value%" == 1) & ("%hhview_value%" == 1))), 1, 0)

I've attached the python script so you can see what happens before this (only the stuff immediately before it should matter).  Do geodatabase raster routinely mess up raster calculator?  Does the syntax need tweaking in some way to deal with geodatabase rasters?

Thanks in advance,
Jacob
0 Kudos
6 Replies
curtvprice
MVP Esteemed Contributor
You should not use "%" signs within raster calculator. You should use model variables which are either raster datasets or raster layers, for example:

Con( "Noview value" == 1 & 
    ((("Beview value" == 0) & ("HHview value" == 0)) |
    (("Beview value" == 1) & ("HHview value" == 1))), 1, 0)


When you open Raster Calculator from inside the model, the valid model elements should be there in the dialog at the upper left with an icon identifying them as model variables (as opposed to raster layers in the current map).

I don't know how the gdb works into this, unless you have temporary dataset names that are confusing things.

Note, if you're working in modelbuilder, it's best to just attach the model (i.e. a tbx file with a model in it) - the python export is very difficult to interpret.
0 Kudos
JacobGjesdahl
New Contributor
I'll keep that in mind on the model, thanks. I'll give the quatation marks a shot.
0 Kudos
JacobGjesdahl
New Contributor
Hmm, this is what if gave me that way:

Executing (Raster Calculator): RasterCalculator Con( "noview_value" == 1 &
    ((("beview_value" == 0) & ("hhview_value" == 0)) |
    (("beview_value" == 1) & ("hhview_value" == 1))), 1, 0) C:\Users\Jacob\Documents\seagate\docs\thesis_GIS\viewsheds\viewshed2.mdb\combined3_1
Start Time: Sat Jun 01 14:28:14 2013
Con( "noview_value" == 1 &
    ((("beview_value" == 0) & ("hhview_value" == 0)) |
    (("beview_value" == 1) & ("hhview_value" == 1))), 1, 0)
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
  File "<expression>", line 1, in <module>
  File "<string>", line 10, in rcexec
AttributeError: 'int' object has no attribute 'save'

Failed to execute (Raster Calculator).
Failed at Sat Jun 01 14:28:14 2013 (Elapsed Time: 0.00 seconds)
0 Kudos
curtvprice
MVP Esteemed Contributor
Do your element names have the underscores? Sometimes it's a bit tricky for the raster calculator parser to recognize rasters if they do not match the model dataset names *exactly*.
0 Kudos
JacobGjesdahl
New Contributor
Yes, everything matches up.  I think I'll just go back to the old formats.
0 Kudos
curtvprice
MVP Esteemed Contributor
Interesting problem...

As for your original reason for switching, file geodatabase is not necessarily the fastest format. Depending on the tools involved, the old grid format or .tif or .img may be faster.
0 Kudos