How can "exists" be used in Modelbuilder to check if a raster dataset exists?
I have checked through all help files, regarding the If / Then and branching. They give a good example to check for a feature class, but i cant get this to work for a raster dataset.
I have created the initial part of a simple model to try to get the calculate value to return a treu / fals eif a raster dataset exists. This modle works when the check is with a feature class and the model contains the feature class as a variable.
However when i use the same logic, but with a raster dataset it does not work, it returns false even though the raster dataset is present in the gdb.
The raster datset and the feature class are both present in the .gdb, and both are present as variables in the model.
i dont understand why this does not work for the raster datset.
any help would be appreciated.
in this example "test1" is a raster dataset and "selection_5" is a feature class
cheers,
[ATTACH=CONFIG]17282[/ATTACH][ATTACH=CONFIG]17283[/ATTACH][ATTACH=CONFIG]17284[/ATTACH]Jonathan
the code that works for the feature class is
expression
x("%selection_5%","%Workspace%")
code block
def x(selection_5, Workspace):
import arcpy
arcpy.env.workspace = Workspace
if arcpy.Exists(selection_5):
return "true"
else:
return "false"
the code that does not work for the raster dataset (gives false when should be true)
expression
x("%test1%","%Workspace%")
code block
def x(test1, Workspace):
import arcpy
arcpy.env.workspace = Workspace
if arcpy.Exists(test1):
return "true"
else:
return "false