<?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: How to add Legend to layer in ModelBuilder in User Conference Questions</title>
    <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676197#M997</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, I think the question is about adding legend by using model builder to automate the process instead of doing it manually..&amp;nbsp; not sure how to add legend in model builder but you can create legend items after adding symbology in arcpy.. If you have any idea about&amp;nbsp; how to add legend with model or script, I can also utilize from that..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Sep 2014 11:29:46 GMT</pubDate>
    <dc:creator>NaimeCelik</dc:creator>
    <dc:date>2014-09-01T11:29:46Z</dc:date>
    <item>
      <title>How to add Legend to layer in ModelBuilder</title>
      <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676193#M993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to add a legend to layer in modelbuilder. Help pages say that I need to use "Apply Symbology From Layer" tool. I have saved my Symbology Layer but it doesn't consist my legend (as I understood a legend can be saved only in Map file). Could you please explain me how to do this correctly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 06:45:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676193#M993</guid>
      <dc:creator>NickPopow</dc:creator>
      <dc:date>2014-08-26T06:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Legend to layer in ModelBuilder</title>
      <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676194#M994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood correctly, you want to add legend with model builder.&lt;SPAN style="line-height: 1.5;"&gt;Apply &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Symbology From Layer extracts &lt;SPAN&gt;Symbology &lt;/SPAN&gt;from a layer ( which is a layer you prepared before) to another layer which does not have symbology.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;As far as I know , there is no tool to include legend in model builder but you could create a script "to add legend" in python and make a tool with that script. Then you can add it to your model. Here same code you can use to create layer from shp and add sybology.&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;symbologyLayer=r"C:\.....\sembology.lyr"&amp;nbsp; # if you want to assign same layer format all the time this can be a path to your symbology &lt;/P&gt;&lt;P&gt;LabelExpression="[Fieldyouwantolabelwith]"&amp;nbsp; #if you want label you can make it parameter if not you do not have to use this label parts&lt;/P&gt;&lt;P&gt;K_shp= arcpy.GetParameterAsText(0)&amp;nbsp; ### your shp file&amp;nbsp; you want to assign symbology&lt;/P&gt;&lt;P&gt;## those above will be your parameters&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument(r"C:\......\my.mxd") &lt;/P&gt;&lt;P&gt;#or mxd = arcpy.mapping.MapDocument("CURRENT") &lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(K_shp,"Layername")&lt;/P&gt;&lt;P&gt;lyr1= arcpy.mapping.Layer("Layername")&lt;/P&gt;&lt;P&gt;arcpy.ApplySymbologyFromLayer_management (lyr1, symbologyLayer)&lt;/P&gt;&lt;P&gt;lyr1.labelClasses[0].expression = LabelExpression&lt;/P&gt;&lt;P&gt;lyr1.showLabels = True&lt;/P&gt;&lt;P&gt;legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0]&lt;/P&gt;&lt;P&gt;legend.autoAdd = True&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;P&gt;arcpy.mapping.AddLayer(df, lyr1, "BOTTOM")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 07:35:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676194#M994</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2014-09-01T07:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Legend to layer in ModelBuilder</title>
      <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676195#M995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I created tool and here how you do it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This&amp;nbsp; is the tool view below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="toolview.jpg" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/6570_toolview.jpg" style="width: 620px; height: 344px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the script for it &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy,os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;symbologyLayer=arcpy.GetParameterAsText(2) &lt;/P&gt;&lt;P&gt;LabelExpression=arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt; for idx, item in enumerate(LabelExpression.split()):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'VISIBLE'==item:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num=idx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddWarning(LabelExpression.split()[idx-1])&lt;/P&gt;&lt;P&gt; LabelExpression="["+LabelExpression.split()[num-1]+"]"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Choose only one field name for label expession")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;K_shp=arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;add_legend= arcpy.GetParameterAsText(3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LayerName=os.path.split(K_shp)[1][:-4]+"_lyr"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(K_shp,LayerName)&lt;/P&gt;&lt;P&gt;lyr1= arcpy.mapping.Layer(LayerName)&lt;/P&gt;&lt;P&gt;arcpy.ApplySymbologyFromLayer_management (lyr1, symbologyLayer)&lt;/P&gt;&lt;P&gt;lyr1.labelClasses[0].expression = LabelExpression&lt;/P&gt;&lt;P&gt;lyr1.showLabels = True&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;P&gt;arcpy.mapping.AddLayer(df, lyr1, "BOTTOM")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if add_legend=='true':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #legend.updateItem(lyr1, styleItem)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.autoAdd = True&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;del mxd&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;IMG alt="toolparameters.jpg" class="jive-image image-2" src="https://community.esri.com/legacyfs/online/6571_toolparameters.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Above is the tool parameters you need to arrange..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only thing that I could not figure out how to add legend itself with arcpy, so you need to manully create and empty legend before you run the script. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 09:09:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676195#M995</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2014-09-01T09:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Legend to layer in ModelBuilder</title>
      <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676196#M996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;if this is just for symbology... right click in the model element (final output) -&amp;gt; properties -&amp;gt; layer symbology tab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 10:09:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676196#M996</guid>
      <dc:creator>NtriankosIoannis</dc:creator>
      <dc:date>2014-09-01T10:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Legend to layer in ModelBuilder</title>
      <link>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676197#M997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, I think the question is about adding legend by using model builder to automate the process instead of doing it manually..&amp;nbsp; not sure how to add legend in model builder but you can create legend items after adding symbology in arcpy.. If you have any idea about&amp;nbsp; how to add legend with model or script, I can also utilize from that..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 11:29:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/user-conference-questions/how-to-add-legend-to-layer-in-modelbuilder/m-p/676197#M997</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2014-09-01T11:29:46Z</dc:date>
    </item>
  </channel>
</rss>

