Skip to main content
3 of 4
edited tags
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Font Formatting in Advanced Label Expression ArcGIS/Python

Almost have this quandry figured out, but inevitably a new problem has popped up. I finally have the "code" part down to do what I want, but now the font formatting isn't acting properly. When I use a simple expression with font tags I can create this image. enter image description here

However, when I use the advanced expression as follows, it returns the garbled image after. I'm using the tags the same way and can't find any reason they shouldn't be working. Without quotes I get a syntax error. My only guess is that I'm missing a quote somewhere, but it makes no sense, to me, why the headers are not coming out right since I copied and pasted that from the simple expression. This is my last hurdle.

def FindLabel ( [SWSID] , [Stn_Name], [First_Date_In_DB], [Last_Date_In_DB], [Percentage_Complete], [First_Date_In_DB1], [Last_Date_In_DB1], [Percentage_Complete1], [First_Date_In_DB2], [Last_Date_In_DB2], [Percentage_Complete2], [First_Date_In_DB3], [Last_Date_In_DB3], [Percentage_Complete3]  ):

lab1 = "T_avg" + "  " + [First_Date_In_DB]+ "  " + [Last_Date_In_DB] + "  " + [Percentage_Complete]+"\n"
lab2 = "Snowfall"+ "  " + [First_Date_In_DB1]+ "  " + [Last_Date_In_DB1] + "  " + [Percentage_Complete1]+"\n"
lab3 = "Snow Depth"+ "  " + [First_Date_In_DB2]+ "  " + [Last_Date_In_DB2] + "  " + [Percentage_Complete2]+"\n"
lab4 = "Rain"+ "  " + [First_Date_In_DB3]+ "  " + [Last_Date_In_DB3] + "  " + [Percentage_Complete3]+"\n"
highlight =  "<bol><clr green='255'>"
endhigh = "</bol></clr>\n"

if float([Percentage_Complete]) >= 90:
lab1 =  "<bol><clr green='255'>" + lab1 + "</bol></clr>\n"
if float([Percentage_Complete1]) >= 90:
lab2 =  "<bol><clr green='255'>" +  lab2 +  "</bol></clr>\n"
if float([Percentage_Complete2]) >= 90:
lab3 =  "<bol><clr green='255'>"+  lab3 + "</bol></clr>\n"
if float([Percentage_Complete3]) >= 90:
lab4 =  "<bol><clr green='255'>"+  lab4+  "</bol></clr>\n"

label = "<und><bol>"+[SWSID]+"</bol></und>"+ "    "+ "<und><bol>"+[Stn_Name]+"</bol></und>\n" + lab1 + lab2 + lab3 + lab4

return label

enter image description here

twistr25
  • 343
  • 4
  • 15