katsuda

make raster layer using each band separately (ArcGIS 10.0)

Discussion created by katsuda on Dec 5, 2012
Latest reply on Dec 6, 2012 by katsuda
Hello,

I am trying to take several classifications of the same image and automate the symbology so that I can visually inspect before going any further.  This might not even be the best way to do it, since I won't be able to apply the symbology from a layer as I can't make a single band raster (after the slice operation on the layers).

So far I have tried to make the bands of the class probability raster into raster layers.  I tried setting up a list of the bands by class name and then using the band index number to name the layer according to the band list.  I'm not sure what I've done wrong, but I get the error message posted below.

Also, this is not going to be made into a tool right away, so if anyone has any ideas of how to apply symbology to a single band raster output from a slice, I would really love to hear from you.  I will be using the natural breaks to divide the data into 2 values.  I don't see that option with the other reclass tools.

Thanks for any help.

krs

#make list of classified rasters 
        classif = arcpy.ListDatasets("cp*", "Raster")
        
        #make list of bands
        bands=["blank", "cld_w_1", "cld_g_2", "ipv_dk_3", "ipv_md_4", "ipv_lt_5", \
               "ipv_brt_6", "conc_7", "soil_8", "decid_9", "drGrs_10", "evgrn_11", \
               "grGrs_12", "bShd_i_13", "tShd_i_14", "bShd_v_15", "tShd_v_16"]
        
        #Loop through list and make raster layers by band
        for tiles in classif:
            for band in bands[1:]:
                arcpy.MakeRasterLayer(tiles, band + ".lyr", "", bands())
                arcpy.SaveToLayerFile_management(band, band + ".lyr", "RELATIVE")

        #list the new layer files
        layers = arcpy.ListDatasets("*.lyr", "All")
        
        #slice the rasters
        for layer in layers:
            outslice = Slice(layer, 2, "NATURAL_BREAKS", 1)
            print(outslice)  # + outslice)


The "blank" at index (0) is there so I can start with index (1) to match up the names.

ERROR messages:
ARCPY ERRORS:


PYTHON ERRORS:
Traceback Info:
  File "C:/scripts/test_make_layers.py", line 44, in main
    arcpy.MakeRasterLayer(tiles, band + ".lyr", "", bands())

Error Info:
     <type 'exceptions.AttributeError'>: 'module' object has no attribute 'MakeRasterLayer'

Outcomes