got my self in a muddle while trying to automate a tool that works for a single point. now trying to automate for many points.
%ID% - the point number i'm using (these range from 1-70)
%max% - a number
in the raster calculator i am making dtm values less than %max% into null values using the following
SetNull("%dtm_1%" < %min%,"%dtm_1%")
This worked for my example when i used dtm_1, however i now want to run this for dtm_1, dtm_2, dtm_3... using dtm_%ID%
if i try SetNull("%dtm_%ID%%" < %min%,"%dtm_%ID%%")
i get an error message
Start Time: Wed Apr 25 13:07:51 2012
SetNull("%dtm_%ID%%" < 69.555,"%dtm_%ID%%")
ERROR 000539: Error running expression: rcexec() <type 'exceptions.RuntimeError'>: ERROR 000732: Input Raster: Dataset %dtm_%ID%% does not exist or is not supported
Failed to execute (Raster Calculator).
Failed at Wed Apr 25 13:07:52 2012 (Elapsed Time: 1.00 seconds)
how do i get this to work properly?
The other posters are right, you cannot "nest" these things. The easiest approach I can think of using is to use the Calculate Value tool with this expression; set the output to be a raster calculator expression, and connect it to the Raster Calculator tool:
'SetNull("{0}_{1} < 69.555, "{0}_{1}")'.format("%dtm_%",%ID%)
I'm assuming you have model elements named "dtm_" and "ID" that will be used in the above expression at runtime, creating a string like:
# %dtm_% = "raster"
# %ID% = 1
SetNull("raster1" < 69.555, "raster1")
Don't forget if all these rasters are in a folder, you can use Iterate Rasters to generate the values of "raster", then you could use a simpler expression like
'SetNull("{0}" < 69.555, "{0}")'.format(r"%raster%")
(the 'r' prefix is required because Iterate Rasters generates pathnames with backslashes that must not be misinterpreted as escape codes)Hope this helps...