<?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: Import symbology from layer - arcpy in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795505#M1790</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have not tested it with tins, but for shapefiles and rasters I use it often. I usually configure in model builder, but have populated a for loop in python to apply the symbology to a set of files as well. To do this, I get a list of layers in a map, and loop through them 1 at a time to apply the symbology. You could also define a function and pass the srcLay object and the data object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My concern is still with the object “data”. Is it a single raster or is it a list? If it is a list, you need to work with them 1 at a time inside a loop.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Mar 2017 19:48:26 GMT</pubDate>
    <dc:creator>JimCousins</dc:creator>
    <dc:date>2017-03-21T19:48:26Z</dc:date>
    <item>
      <title>Import symbology from layer - arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795502#M1787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am trying to update the symbology of a raste layer using an existing layer file with 2 different functions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;- update layer&lt;/P&gt;&lt;P&gt;- apply symbology from layer&lt;/P&gt;&lt;P&gt;The same function works with shapefiles, though.&lt;/P&gt;&lt;P&gt;Nothing happens, still the code runs till the end with no error message, which makes it pretty difficult to find the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;
workDir &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'C:/0.STUDY PROJECT/Maps/'&lt;/SPAN&gt;

mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;template&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
dfs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dfs&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;# clip is obtained interpolating a point shapefile with natural neighbours method and clipped with a polygon shapefile&lt;/SPAN&gt;
clip &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:\\0.STUDY PROJECT\\MapsKulmbach\\processed_data\\clip"&lt;/SPAN&gt;

depth_data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;clip&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;df&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; depth_data&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

srcLay &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; workDir &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"depthSymbology.lyr"&lt;/SPAN&gt;
srcLayObj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;srcLay&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# try function 1&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;df&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; depth_data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; srcLayObj&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# try function 2&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ApplySymbologyFromLayer_management &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;depth_data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; srcLayObj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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;/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;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know what a reason could be?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:11:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795502#M1787</guid>
      <dc:creator>martinaraffellini</dc:creator>
      <dc:date>2021-12-12T09:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Import symbology from layer - arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795503#M1788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is difficult to pin this down without seeing the entire script. However, is "data" returning a single raster object, or a list of rasters in a directory location? Try hardcoding a single raster layer, and running that through. I have a similar script that I use without troubles:&lt;/P&gt;&lt;P&gt;# Purpose: This funtion applies a lyr file to set symbology of a layer in the map.&lt;BR /&gt;# This function takes 2 arguments:&lt;BR /&gt;# 1) the layer to set symbolgy for&lt;BR /&gt;# 2) the symbolgy source&lt;BR /&gt;# Works very well from within a model&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;import sys&lt;BR /&gt;import string&lt;BR /&gt;import arcpy.mapping&lt;BR /&gt;from arcpy import env&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;# Local Variables from input&lt;BR /&gt;Layer2Symbolize = sys.argv[1]&lt;BR /&gt;lyrSource = sys.argv[2]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process - Apply Symbology From Layer&lt;BR /&gt;arcpy.ApplySymbologyFromLayer_management(Layer2Symbolize, lyrSource)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 15:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795503#M1788</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2017-03-21T15:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Import symbology from layer - arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795504#M1789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;The whole code is too long but i can add a few lines in the script above.&lt;/P&gt;&lt;P&gt;Does your code work with shapefiles, rasters, TIN and layerfiles?&lt;/P&gt;&lt;P&gt;I can manage only with shp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:25:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795504#M1789</guid>
      <dc:creator>martinaraffellini</dc:creator>
      <dc:date>2017-03-21T16:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Import symbology from layer - arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795505#M1790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have not tested it with tins, but for shapefiles and rasters I use it often. I usually configure in model builder, but have populated a for loop in python to apply the symbology to a set of files as well. To do this, I get a list of layers in a map, and loop through them 1 at a time to apply the symbology. You could also define a function and pass the srcLay object and the data object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My concern is still with the object “data”. Is it a single raster or is it a list? If it is a list, you need to work with them 1 at a time inside a loop.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 19:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795505#M1790</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2017-03-21T19:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Import symbology from layer - arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795506#M1791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no, it is a single raster. I have to put it in a loop later, but now i am trying one step&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Mar 2017 15:23:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/import-symbology-from-layer-arcpy/m-p/795506#M1791</guid>
      <dc:creator>martinaraffellini</dc:creator>
      <dc:date>2017-03-25T15:23:57Z</dc:date>
    </item>
  </channel>
</rss>

