I do not have a very good understanding of python and have attempted to write a code block so that my model will skip rasters that do not contain any information and continue the process with rasters that do contain information.
This is pertinent part of the model:
My current issue is that I keep getting this error:
Executing (Calculate Value):
CalculateValue getValue(%Check Raster%) "def getValue(CheckRaster):\n import arcpy\n if "Has Values": return True\n if "Has No Values": return False" Variant
Start Time: Fri Oct 30 10:16:54 2015
ERROR 000539:
SyntaxError: invalid syntax (, line 1) Failed to execute (Calculate Value).
This is what my calculate value tool currently looks like:
Any ideas to how I could change the code so that there are not any more syntax errors? (The complete model can be found here.)
EDIT: The below answers were helpful but they have not entirely circumvented the problem yet. The check raster tool that I am using seems to always give an output that "Has Values" even though the following error will occur during Raster To Polygon: ERROR 010151: No features found in C:\Users\boll0230\Documents\ArcGIS\Suitability_stuff\03\Scratch\polygon_03.shp. Possible empty feature class.
I believe this means their is a problem with the check raster tool I have. Perhaps this has become more complicated that it needs to be. Is there a possible code that could be written in the calculate value tool that would check Raster@Threshold for the presence of features?
import arcpy
here. It can drastically slow down your code.arcpy
does not need to be loaded once in ArcMap.