I converted a KML to a feature class and no longer have access to the symbology set in the original KML. I'm trying to re-create this by creating a new field that stores identifying information useful in creating the layer symbology.
There are three different 'keywords' in the original attribute table that would be useful in a control structure that determines the appropriate symbology type. I need to search the string for these keywords, but I'm having trouble.
The sample code below is just to get the control structure working -- I know I need to use an update cursor to change / add field addtributes.
Here is my code:
# Import ESRI Python module import arcpy # Declare variables used in this script #featureClass = r'C:\arbitraryLocationOnDisk' oldField = 'FolderPath' newField = 'HabitatType' # Restricted by domain: HabitatType # 1. Critical Habitat # 2. Corridors and Key Habitat Areas # 3. Global IBA's rows = arcpy.SearchCursor(featureClass) for row in rows: fieldValue = row.getValue(oldField) if fieldValue.find('Global'): print 'Global IBA' elif fieldValue.find('Corridors'): print 'Corridors and Key Habbitat Areas' elif fieldValue.find('Critical'): print 'Critical Habitat' else: print 'Unrecognized habitat type: ' + fieldValue del fieldValue except: arcpy.GetMessages() finally: del rows
The problem I'm experiencing is that after every single row, I'm getting 'Global IBA' despite the fact that not every row contains the substring 'Global'.