Select to view content in your preferred language

Advanced label expression crashing 10.2.2

1261
9
Jump to solution
07-18-2014 10:20 AM
DavidWhitehead
Deactivated User

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. table.jpg

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DavidWhitehead
Deactivated User

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.

View solution in original post

0 Kudos
9 Replies
IanMurray
Honored Contributor

Try return label instead of return FindLabel, FindLabel is your function, label is your string you built which you want to show up. 

0 Kudos
DavidWhitehead
Deactivated User

Should have seen that earlier, but doesn't fix the problem, still crashing.

0 Kudos
IanMurray
Honored Contributor

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.

0 Kudos
DavidWhitehead
Deactivated User

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....

0 Kudos
IanMurray
Honored Contributor

Mind posting the file and let me give it a go?

0 Kudos
DavidWhitehead
Deactivated User

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.

0 Kudos
IanMurray
Honored Contributor

Ah, so it wasn't your label expression crashing, it was ArcMap crashing.  Glad you got it worked out.

DavidWhitehead
Deactivated User

Yeah, it was the whole program! Relatively easy fix, just took effort figuring out what it was. Thanks for the help!

0 Kudos
DavidWhitehead
Deactivated User

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.

0 Kudos