Hi,
Before I dive into more detail. I have an issue with a layer that somebody wrote this expression into this labeling expression. I have the Drawing Alert that tells me . I am trying to understand this and I am not sure how to fix it.
The layer I had was from an original layer came from the upper management and they did this for the whole country and I had to use it to clipped it to smaller area for our project. So when you clipped the layer , I believe some of the expression did not work in the label expression.
So here is the Expression from the Labeling section is what I have here from an original layer:
def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME], [NATIONAL_TRAIL_DESIGNATION] ):
if [ADMIN_ORG].startswith('02'):
s='.'
if [ADMIN_ORG].startswith('0201'):
return [TRAIL_NO] [2:]
else:
return [TRAIL_NO].split(s,1)[0]
elif [ADMIN_ORG].startswith('0919') or [ADMIN_ORG] .startswith('0922') or [ADMIN_ORG] .startswith('0903')or [ADMIN_ORG] .startswith('0913'):
return [TRAIL_NO] [2:]
elif [ADMIN_ORG] .startswith('0909') or [ADMIN_ORG] .startswith('0907'):
return [TRAIL_NO] [2:].replace('-','')
elif [ADMIN_ORG] .startswith('0904'):
return [TRAIL_NO] [1:]
elif [ADMIN_ORG].startswith('0915'):
return [TRAIL_NO][4:]
elif [ADMIN_ORG].startswith('08'):
if [ADMIN_ORG].startswith('0805') or [ADMIN_ORG].startswith('0810'):
return [TRAIL_NO].replace('TRBS','').replace('TR','')[1:]
else:
return [TRAIL_NO].replace('TRBS','').replace('TR','')
elif [ADMIN_ORG].startswith('04'):
if [ADMIN_ORG].startswith('0419'):
return [TRAIL_NO] [1:]
elif [ADMIN_ORG].startswith('0402'):
return [TRAIL_NO][:3]
elif [MANAGING_ORG].startswith('0402'):
return [TRAIL_NO][:3]
elif [ADMIN_ORG].startswith('040702') and [TRAIL_NO].startswith('32000.'):
return [TRAIL_NO].replace('32000','').replace('.','')
elif [ADMIN_ORG].startswith('040702'):
return [TRAIL_NO][2:]
else:
return [TRAIL_NO][1:]
elif [ADMIN_ORG].startswith('0303'):
return [TRAIL_NO] [2:]
elif [MANAGING_ORG].startswith('031204'):
return [TRAIL_NO].replace('MT-','')
else:
return [TRAIL_NO].lstrip("0").replace('.', '-').replace('TER-','').replace('TRD','')
I have the clippped layer here and I have looked into the attributes and I can see some of the split it mention in the expression and yes I can see some of the numbers like this 157.2 or "Name of trail".456
The Problem is the error that tells me
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 7, in FindLabel
AttributeError: 'NoneType' object has no attribute 'split'
I am clueless here and I am not sure what the line 7 is and I am not sure where to find it.
Please excuse my grammar here. I am deaf and I try my best to understand how it works and it will help me to understand better down in the road should I came up the same thing in the future...
Thanks GIS friends !
I am in the VDI, Citrix, and ArcGIS Pro 3.3.4.