I have a classified raster with a class value that is a very long concatenated string name (Class_Name below). I'm trying to use arcpy to generate integer labels ranging from 1-24 (which are the third concatenated sub-group in these long strings). Here's an example of a previous (manually manipulated) similar raster attribute table.
So far I've been manually using search criteria in ERDAS to find classes belonging to the same group such as:
$"Class_Names" contains "-14.01-" or $"Class_Names" contains "-14.02-" or $"Class_Names" contains "-14.03-"
I've tried using the following code (as a trial for the first two classes) with LIKE in a for loop with UpdateCursor, but I get a syntax error for my LIKE statement.
in_table = 'l12wm_agsup02.img'
field_names = ['Class_Name', 'crop']
with arcpy.da.UpdateCursor(in_table, field_names) as cursor:
for row in cursor:
if row[0] 'LIKE \'1.%\'':
row[1] = 1
elif row[0] 'LIKE \'2.%\'':
row[1] = 2
cursor.updateRow(row)
I've looked at Using LIKE clause in update cursor gives syntax error? and https://community.esri.com/thread/87848 but can't figure out how to use LIKE in the if else statements instead as a where clause in UpdateCursor.
I'm using ArcMap 10.5, Python 2.7