<?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: Using Python Labeling Expressions in ArcGIS Pro in Natural Resources Questions</title>
    <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280251#M297</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you need a Python code block with "if" conditional statments to decode the first 3 letters of your ATTRIBUTE field, as shown here:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="/legacyfs/online/395333_ArcGIS Pro Python.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;All details available here:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/help/mapping/text/specify-text-for-labels.htm" title="http://pro.arcgis.com/en/pro-app/help/mapping/text/specify-text-for-labels.htm"&gt;Specify text for labels—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the &amp;lt;FNT&amp;gt;&amp;lt;/FNT&amp;gt; pseudo HTML tages, you can apply some formatting to the labels such as color, size, police... but it will be limited. To me, it won't be possible to apply Halo, Callout and any advanced formatting...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Label classes as you did was the right way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Jan 2018 13:48:29 GMT</pubDate>
    <dc:creator>VincentLaunstorfer</dc:creator>
    <dc:date>2018-01-31T13:48:29Z</dc:date>
    <item>
      <title>Using Python Labeling Expressions in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280250#M296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am definitely a novice when it comes to scripting. I know there is a way to do what I am asking, but I lack the skills to do it right now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a wetlands shapefile that has many wetland features in it that need to be labeled according to their attributes. What I mean by this is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;All forested wetland features need to be labeled a dark green Arial 10 pt. bold with a 1 pt. white halo&lt;/P&gt;&lt;P&gt;All riverine features need to be labeled a deep blue Arial 10 pt. bold with 1 pt. white halo&lt;/P&gt;&lt;P&gt;All ponds need to be labeled a light blue Arial 10 pt. bold with 1 pt. white halo&lt;/P&gt;&lt;P&gt;etc..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The shapefile has a field in the attribute table called "ATTRIBUTE" which contains NWI code for what type of wetland the feature is.&lt;/P&gt;&lt;P&gt;So, forested wetland's "ATTRIBUTE" field starts with the letters "PFO"&lt;/P&gt;&lt;P&gt;Riverine features' "ATTRIBUTE" field starts with the letter "R"&lt;/P&gt;&lt;P&gt;Ponds' "ATTRIBUTE" field starts with "PUB"&lt;/P&gt;&lt;P&gt;and etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The actual NWI code in the "ATTRIBUTE" field is longer, but the first three letters or so is what distinguishes a forested wetland from a scrub-shrub wetland&amp;nbsp;&lt;/P&gt;&lt;P&gt;ex. PFO1C is a forested wetland while PSS1C is a scrub-shrub wetland. So, I just need the script to use a "begins with" type distinguishment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used SQL to define classes in the Label Manager and then manually modified the text symbol for each class, but what would really help is to be able to have a python script saved that can do the symbols and the classifying in one step so-to-speak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if anyone needs this, but the SQL expression I have been using in each label class is simply:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ATTRIBUTE LIKE 'PFO%'&lt;/P&gt;&lt;P&gt;and I just substitute "PFO" for whatever I need for that labeling class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached an image of what I want to do. I hope for the same result as this (which I did by creating label classes and using the simple SQL expression above in each class and then manually modifying the symbols in each class) but just in a single python script. Could anybody help me get started? I just don't understand how to structure the script or use appropriate syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;IMG alt="An example of the type of labeling I would like to automate." class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392787_Example_Labeling.JPG" style="width: 620px; height: 447px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280250#M296</guid>
      <dc:creator>JosephGerland</dc:creator>
      <dc:date>2018-01-12T15:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Labeling Expressions in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280251#M297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you need a Python code block with "if" conditional statments to decode the first 3 letters of your ATTRIBUTE field, as shown here:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="/legacyfs/online/395333_ArcGIS Pro Python.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;All details available here:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/help/mapping/text/specify-text-for-labels.htm" title="http://pro.arcgis.com/en/pro-app/help/mapping/text/specify-text-for-labels.htm"&gt;Specify text for labels—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the &amp;lt;FNT&amp;gt;&amp;lt;/FNT&amp;gt; pseudo HTML tages, you can apply some formatting to the labels such as color, size, police... but it will be limited. To me, it won't be possible to apply Halo, Callout and any advanced formatting...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Label classes as you did was the right way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jan 2018 13:48:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280251#M297</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2018-01-31T13:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Labeling Expressions in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280252#M298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you can use halo and other effects, since as far as I can deduce all the labels will have the same halo setting. The only thing that needs to be influenced is the color. The effect you can get is this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/395340_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you will need to do is this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Define manually the symbol for the labels to be Arial 10pt and Halo white 1pt. This is what all labels have in common&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Define the&amp;nbsp;class for the label like this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/395341_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is basically this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; FindLabel &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;Wetlands&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; label_text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;Wetlands&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_startswith &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'PFO'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;CLR red='0' green='100' blue='30'&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;'R'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;CLR red='30' green='80' blue='160'&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;'PUB'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;CLR red='50' green='200' blue='240'&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; color &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;CLR red='130' green='130' blue='130'&amp;gt;"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; start &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dct_startswith&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;keys&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; label_text&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;upper&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;startswith&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;start&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dct_startswith&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;start&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; color &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; label_text &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;/CLR&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What it does is read the attribute with the wetlands&amp;nbsp;values (line 1 and 2). Next it defines a dictionary that in this case has 3 keys (the values we want to check the start of the wetlands class on). See lines 3 to 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As default color we define a light grey color RGB intensity will be set to 130 (see line 7) and then we start to loop through the keys (PFO, R and PUB) and we check if the wetland value starts with this value. If so the color is adjusted accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end we return the color setting, along with the actual label text and the closing tag for the color.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that is basically all you need to do. Change the colors as you please and add additional values to the dictionary if you need to distinguish more classes.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280252#M298</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T13:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Labeling Expressions in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280253#M299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, that works perfectly! Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Feb 2018 16:06:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/280253#M299</guid>
      <dc:creator>JosephGerland</dc:creator>
      <dc:date>2018-02-05T16:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Labeling Expressions in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/1050237#M966</link>
      <description>&lt;P&gt;Is it possible to set halo only using python?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 18:23:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/natural-resources-questions/using-python-labeling-expressions-in-arcgis-pro/m-p/1050237#M966</guid>
      <dc:creator>anyry</dc:creator>
      <dc:date>2021-04-22T18:23:27Z</dc:date>
    </item>
  </channel>
</rss>

