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 )
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 ?

  • When you use Add Data from within ArcMap, do you get the colored raster displaying correctly? Or is it black and white as well?
    – Paul
    Commented Aug 3, 2014 at 14:13
  • i get colored raster correctly.see artwork21 answer
    – newGIS
    Commented Aug 6, 2014 at 7:36

2 Answers 2


Use the Make Raster Layer Tool rather than arcpy.mapping.Layer:

Creates a raster layer from an input raster dataset or layer file. The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved.

This tool can be used to make a temporary layer, so you can work with a specified subset of bands within a raster dataset.

  • That link doesn't work for me.
    – Paul
    Commented Aug 3, 2014 at 19:12
  • Fixed link. Try again. Commented Aug 3, 2014 at 19:23

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.