Model Builder Tool that...

1145
11
Jump to solution
07-15-2013 07:39 AM
ShikoNjuno
Occasional Contributor
Hello folks, I'm trying to find a tool on model builder that checks a list of user input values against an existing shapefile. Then, if it does exists, data from the corresponding raster files  will be extracted.
I realize this may require two or more different tools but if anyone can suggest at least one that checks existence of data, that'll be really helpful to get me started.
Thanks.

Shiko
0 Kudos
11 Replies
ShikoNjuno
Occasional Contributor
So I'm up to the Script Tool point with the model.....I switched it up a little but I don't think that should cause the error message below:

Expression
x(%Selection%, %Workspace%)

Code
def x(Selection,Workspace):
  arcpy.env.workspace = Workspace
  if all in [arcpy.Exists(s) for s in Selection]:
    return True
  else:
    return False

Data Type
Boolean

After running:
ERROR 000539: SyntaxError: unexpected character after line continuation character (<expression>, line 1)
Failed to execute (Selection_Exist_Check).
Failed at Tue Jul 16 13:51:52

Note: This was happening even prior to your model suggestion, which works well up until this point. Also, Workspace is the shapefile of interest.
Thanks
0 Kudos
ShitijMehta
Esri Regular Contributor
arcpy.env.worspace should be a workspace like a folder or a geodatabase and not a path to a specific shapefile. May be this is the issue.

or

when you pass a path in the expression you should do it like this: r"%Workspace%".
or

This error code covers a number of Python errors:

Example error 1: exceptions.TypeError: cannot concatenate 'str' and 'int' objects.
The above is a Python-specific error. The calculation is attempting to add or concatenate a string and a number.

Example error 2: Invalid field shape@distance
The above is an error using the geometry object. The distance method is not a valid method of the geometry object.
0 Kudos