I'm developing an ArcGIS tool by Python. Below is a part of the inputs:
StudyArea = arcpy.GetParameterAsText(0) LandCover = arcpy.GetParameterAsText(1) gridcode = arcpy.GetParameterAsText(2)
gridcode is a field from LandCover.
gridcode aims to derive the field which contains land cover class code.
Then I try to select some land cover types (land cover code < 17 and = 21), and the code I write is:
arcpy.SelectLayerByAttribute_management("LC_test","NEW_SELECTION",'gridcode<17 or gridcode=21')
"LC_test" is the feature layer of LandCover
The problem is: in the LandCover shapefile, if the field of Land Cover code is named as "gridcode" as well, the tool works fine.
If the field name is not "gridcode", the tool fails to execute. The error is "invalid expression".
Can anyone help me with this?