Sunday 17 June 2018

arcgis desktop - Adding ECW file to MXD with ArcPy?


I'm using Desktop 10.2 and I tried ,with this script, to add ecw file to mxd's but the result is a black & white raster(stretched symbology) instead of colored raster(RGB composite symbology) :


import arcpy
import arcpy.mapping
import os
import sys
from arcpy import env
import string



env.workspace = r"C:\project"
for mxd in arcpy.ListFiles("*.mxd"):
print mxd
mapdoc = arcpy.mapping.MapDocument(r"C:\project\\" + mxd)
df = arcpy.mapping.ListDataFrames(mapdoc, "Layers")[0]
Layer1 = arcpy.mapping.Layer(r"C:\project\layers\F1292_KVISH6_25CM_.ecw")
arcpy.mapping.AddLayer(df ,Layer1 )
mapdoc.save()
del mxd # i added


this is the image i get: black & white image


i don't know how to changed the python script so i will get RGB colored image ?



Answer



Manually save a layer file of the raster in the r g b format. Then, use the same code as you did, but reference the saved .lyr file instead.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...