I have been at this for a while and a little disappointed in the amount of money spent on this software and some of the seemingly easy things it should be able to do that it cannot. For example, being able to display a table of values from the attribute table as a label. So since that is not possible I have been trying to use my minimal coding skills to create a functional advanced expression. I have come up with the following
def FindLabel ([SWSID], [Stn_Name], [First_Date], [Last_Date], [Percentage], [First_Da_1], [Last_Dat_1], [Percenta_1], [First_Da_2], [Last_Dat_2], [Percenta_2], [First_Da_3], [Last_Dat_3], [Percenta_3]):
label = ""
flds = [[SWSID]]
for fld in flds:
label += "<und><bold>[SWSID]</bold></und> <und><bold>[Stn_Name]</bold></und>\n" + "T_avg" + " " + [First_Date]+ " " + [Last_Date] + " " +[Percentage]+"\n" + "Snowfall" + " " + [First_Da_1]+ " " + [Last_Dat_1] + " " +[Percenta_1]+"\n"+ "Snow Depth" + " " + [First_Da_2]+ " " + [Last_Dat_2] + " " +[Percenta_2]+"\n"+ "Rain" + " " + [First_Da_3]+ " " + [Last_Dat_3] + " " +[Percenta_3]+"\n"
return FindLabel
When I try to do a verify, it crashes. So I thought, maybe it is too many variables, so I modified just for testing purposes to this
def FindLabel ([SWSID], [Stn_Name], [First_Date]):
label = ""
flds = [[SWSID]]
for fld in flds:
label += "<und><bold>[SWSID]</bold></und> <und><bold>[Stn_Name]</bold></und>\n" + "T_avg" + " " + [First_Date]
return FindLabel
Still crashing.... Any ideas on how to fix this issue or a different way to go about creating a table label. I'd like it to look something like below. It needs the row names but does not need the column headers in row 2, I have resigned to that.
Solved! Go to Solution.
The pathway between my ArcGIS and Python folder was corrupt or messed up in some fashion. A repair of the software seemed to fix everything up.
Try return label instead of return FindLabel, FindLabel is your function, label is your string you built which you want to show up.
Should have seen that earlier, but doesn't fix the problem, still crashing.
Why are you using a for loop? SWSID is a single field, there is nothing to loop through, for each feature it will return the value in that field.
have you tried making you label =
"<und><bold>[SWSID]</bold></und> | <und><bold>[Stn_Name]</bold></und>\n" + "T_avg" + " " + [First_Date]+ " " + [Last_Date] + " " +[Percentage]+"\n" + "Snowfall" + " " + [First_Da_1]+ " " + [Last_Dat_1] + " " +[Percenta_1]+"\n"+ "Snow Depth" + " " + [First_Da_2]+ " " + [Last_Dat_2] + " " +[Percenta_2]+"\n"+ "Rain" + " " + [First_Da_3]+ " " + [Last_Dat_3] + " " +[Percenta_3]+"\n" |
I'm guessing all those in brackets are fields that are part of your shapefile or feature class.
To add to my initial frustration, if I try to verify the original function that ArcGIS populates in the box, it also crashes the program. So, who knows....
Mind posting the file and let me give it a go?
Actually got it figured out after talking with ESRI support. I had a rogue version of Python that was interferring with what was installed with ArcGIS. A reinstall to re-set the paths cleared it up.
Ah, so it wasn't your label expression crashing, it was ArcMap crashing. Glad you got it worked out.
Yeah, it was the whole program! Relatively easy fix, just took effort figuring out what it was. Thanks for the help!
The pathway between my ArcGIS and Python folder was corrupt or messed up in some fashion. A repair of the software seemed to fix everything up.