<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Working with labels using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580732#M73680</link>
    <description>&lt;P&gt;lblClass.expression = '$feature.Area_Name +": " +$feature.&lt;SPAN&gt;GRADEID'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;should be something like this, I think?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 02:10:50 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2025-01-31T02:10:50Z</dc:date>
    <item>
      <title>Working with labels using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580730#M73679</link>
      <description>&lt;P&gt;I am working on a script/geoprocessing tool where, once a month, my users can export the feature classes they need from an Enterprise Geodatabase to a File Geodatabase.&amp;nbsp; So they can essentially do their analysis without impacting the source data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I aim to create a tool that extracts the feature classes and adds them to the map I did.&amp;nbsp; Then, I want to symbolize the feature class, which I've also gotten working on.&amp;nbsp; However, now I am trying to label the features for them, and I can get it to work, but I was trying to do more with it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each protected area polygon has a NAME and a GRADEID.&amp;nbsp; I want to concatenate those two fields so it reads "Protected Area Name: GRADEID #".&amp;nbsp; The code I have so far will turn on the labels for either the Protected area name or the Grade ID, but it doesn't return anything when I try to return both.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample of the table with the names and grades.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-30 185547.png" style="width: 336px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124428i699A54F7C2FD9D37/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-30 185547.png" alt="Screenshot 2025-01-30 185547.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is what my map currently looks like.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Just the GradIDs" style="width: 522px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124430iAB6F48526F6F8798/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-30 185726.png" alt="Just the GradIDs" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Just the GradIDs&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Finally here is my code so far.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import arcpy.mp as map
arcpy.env.overwriteOutput = True

arcpy.env.workspace = arcpy.GetParameterAsText(0)

arcpy.conversion.FeatureClassToGeodatabase(
    Input_Features=r"C:\PPCAnalysis\PPCAnalyis\ISRB_DATA.sde\DBO.FireStations;C:\PPCAnalysis\PPCAnalyis\ISRB_DATA.sde\DBO.Hydrants;C:\PPCAnalysis\PPCAnalyis\ISRB_DATA.sde\DBO.Idaho;C:\PPCAnalysis\PPCAnalyis\ISRB_DATA.sde\DBO.ProtectedAreas",
    Output_Geodatabase=r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb"
)

arcpy.env.workspace = r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb"

aprx = map.ArcGISProject("CURRENT")
for m in aprx.listMaps("PPCAnalyisData"):
    m.addDataFromPath(r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb\FireStations")
    m.addDataFromPath(r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb\Hydrants")
    m.addDataFromPath(r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb\Idaho")
    m.addDataFromPath(r"C:\PPCAnalysis\PPCAnalyis\PPC_AnalyisisData.gdb\ProtectedAreas")

for m in aprx.listMaps("PPCAnalyisData"):
    for lyr in m.listLayers("ProtectedAreas"):
        if lyr.isFeatureLayer:
            lyr.transparency = 50
            sym = lyr.symbology
            sym.updateRenderer('UniqueValueRenderer')
            sym.renderer.fields = ["NAME"] 
            lyr.symbology = sym

updatedProtectedAreas = "ProtectedAreas"

m = aprx.listMaps("PPCAnalyisData")[0]

for m in aprx.listMaps("PPCAnalyisData"):
    for lyr in m.listLayers("ProtectedAreas"):
        lblClass = lyr.listLabelClasses()[0]
        print(lblClass.name)
        lblClass.expression = "$feature.GRADID"  
        lyr.showLabels = True&lt;/LI-CODE&gt;&lt;P&gt;Any suggestions on how I can get the names and the grades to print together would be great. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 02:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580730#M73679</guid>
      <dc:creator>ColeNelson</dc:creator>
      <dc:date>2025-01-31T02:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Working with labels using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580732#M73680</link>
      <description>&lt;P&gt;lblClass.expression = '$feature.Area_Name +": " +$feature.&lt;SPAN&gt;GRADEID'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;should be something like this, I think?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 02:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580732#M73680</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-01-31T02:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Working with labels using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580733#M73681</link>
      <description>&lt;P&gt;I tried that, and nothing happened.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 02:16:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580733#M73681</guid>
      <dc:creator>ColeNelson</dc:creator>
      <dc:date>2025-01-31T02:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Working with labels using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580735#M73682</link>
      <description>&lt;P&gt;Whoops I typed in a field name wrong, it's working now&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 03:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580735#M73682</guid>
      <dc:creator>ColeNelson</dc:creator>
      <dc:date>2025-01-31T03:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Working with labels using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580833#M73684</link>
      <description>&lt;P&gt;Lol glad it worked.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:50:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/working-with-labels-using-arcpy/m-p/1580833#M73684</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-01-31T14:50:56Z</dc:date>
    </item>
  </channel>
</rss>

