Hello!
I am trying to update the symbology of a raste layer using an existing layer file with 2 different functions:
- update layer
- apply symbology from layer
The same function works with shapefiles, though.
Nothing happens, still the code runs till the end with no error message, which makes it pretty difficult to find the error.
data <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>Layer<SPAN class="punctuation token">(</SPAN>raster<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># raster path defined above</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>AddLayer<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">,</SPAN> depth_data<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># data frame defined above</SPAN>
srcLay <SPAN class="operator token">=</SPAN> workDir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Symbology.lyr"</SPAN> <SPAN class="comment token"># working directory defined above</SPAN>
srcLayObj <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>Layer<SPAN class="punctuation token">(</SPAN>srcLay<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># this function:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>UpdateLayer<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">,</SPAN> data<SPAN class="punctuation token">,</SPAN> srcLayObj<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># or alternatively:</SPAN>
<SPAN class="comment token"># arcpy.ApplySymbologyFromLayer_management (data, srcLayObj)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Do you know what a reason could be?
Thank you