<?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 Change Alpha channel on multiple ecw tiles in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717060#M55594</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Trying to save myself hours of work here, I have a layer with &amp;gt;300 ecw tiles from aerial photography all of which need the alpha channel updated to be band 4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to achieve this using python, if so what functions should I be looking at to change these attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not done anything in python but have experience in vb.net and SQL. So am hoping to add python to my bag of tricks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any code examples or hints will be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Aug 2013 11:37:12 GMT</pubDate>
    <dc:creator>ScottClune</dc:creator>
    <dc:date>2013-08-21T11:37:12Z</dc:date>
    <item>
      <title>Change Alpha channel on multiple ecw tiles</title>
      <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717060#M55594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Trying to save myself hours of work here, I have a layer with &amp;gt;300 ecw tiles from aerial photography all of which need the alpha channel updated to be band 4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to achieve this using python, if so what functions should I be looking at to change these attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not done anything in python but have experience in vb.net and SQL. So am hoping to add python to my bag of tricks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any code examples or hints will be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 11:37:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717060#M55594</guid>
      <dc:creator>ScottClune</dc:creator>
      <dc:date>2013-08-21T11:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Change Alpha channel on multiple ecw tiles</title>
      <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717061#M55595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Scott,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why not just create a LYR file from a raster with the alpha band already set and then create a short script to updated the other raster layers in your mxd. Look up this fucntion, "UpdateLayer (arcpy.mapping)".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 23:00:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717061#M55595</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2013-08-21T23:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change Alpha channel on multiple ecw tiles</title>
      <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717062#M55596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Thanos,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have looked at arcpy.mapping.UpdateLayer and it looks as though it will achieve what I want it to do..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;using the example shown in the help I have created an mxd for testing with all the ecw files in it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I then created a lyr file with one ecw file with the alpha channel changes implemented.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I called the layers in my files updateLayer and sourceLayer to avoid confusion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is my code..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument(r"E:\Scott Created GIS Files\MXDs\UpdateImagery2.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "updateLayer", df)[0]
sourceLayer = arcpy.mapping.Layer(r"E:\Scott Created GIS Files\MXDs\sourceLayer.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)
mxd.saveACopy(r"E:\Scott Created GIS Files\MXDs\UpdateImagery_3.mxd")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try t run this script in pythonwin I get a rather unhelpful error&amp;nbsp; "ValueError: LayerObject: Unexpected error" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;could this possibly be a security issue with windows 7 allowing python access to the file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have googled the error but have not found any helpful information, have you seen this before with this function.?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help would be great.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:42:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717062#M55596</guid>
      <dc:creator>ScottClune</dc:creator>
      <dc:date>2021-12-12T06:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Change Alpha channel on multiple ecw tiles</title>
      <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717063#M55597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've tried it like this, and its fine,&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxd_path) df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&amp;nbsp; sourceLayer = arcpy.mapping.Layer(layerfile_path)&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd,'',df): &amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.isRasterLayer == True: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(df, lyr, sourceLayer, True) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name&amp;nbsp; mxd.saveACopy(r"E:\Test2.mxd")&amp;nbsp; del lyr, mxd&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 01:36:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717063#M55597</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2013-08-22T01:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Change Alpha channel on multiple ecw tiles</title>
      <link>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717064#M55598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Theros,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I realised after my last post that I was trying to update a group layer rather than a raster layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and when I removed the group layer the original code worked after I added in the loop through the raster layers..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your assistance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it has been much appreciated and I hope I can repay the favour one day.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers:)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 03:13:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-alpha-channel-on-multiple-ecw-tiles/m-p/717064#M55598</guid>
      <dc:creator>ScottClune</dc:creator>
      <dc:date>2013-08-22T03:13:33Z</dc:date>
    </item>
  </channel>
</rss>

