2 Replies Latest reply on Aug 18, 2011 3:35 PM by PYadav-esristaff

    ArcGIS 10 - selecting attributes from multiple bands

      I would like to know the syntax for arcpy.sa or Raster Calculator to select the following:

      1.  Band_1 from a raster where the Value is something specific.  Do I use ExtractByAttributes?  If so, what is the syntax to choose Band_1 from a multiband raster?
      2.  Select from a combination of all three rasters like "Band_1","Value = 112"; "Band_2, "Value = 115"; "Band_3","Value = 5".  I have no idea of the syntax for this. 

      http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000029000000.htm explains that you can use multiband rasters, but doesn't explain the syntax to do this.

      Any help would be greatly appreciated.


        • Re: ArcGIS 10 - selecting attributes from multiple bands
          In a python script using arcpy, to select a single band from a multi-band raster, just append "\\Layer_X" onto the path name.  For example, my multi-band raster is "D:\\temp\\test.img" (or r"D:\temp\test.img" or 'D:/temp/test.img').  The second band would be "D:\\temp\\test.img\\Layer_2".  Actually it could be called something other than Layer_X, you just have to look at how it is named when you load the raster into ArcMap (in ArcGIS 9 I think they were all named band_X).

          To get the part of a raster with a specific value in a python script, you can use simple conditionals.  I'm not totally sure this is what you want, but maybe it will help:
          import arcpy
          input_raster = "D:\\temp\\test.img"
          band1_obj = arcpy.sa.Raster(input_raster+"\\Layer_1")
          band2_obj = arcpy.sa.Raster(input_raster+"\\Layer_2")
          band3_obj = arcpy.sa.Raster(input_raster+"\\Layer_3")
          output_obj = (band1_obj == 112) & (band2_obj == 115) & (band3_obj == 5)

          I'm not sure how to do this in raster calculator.  I was actually trying to figure that out when I found your post, but it is probably very similar though.
          • Re: ArcGIS 10 - selecting attributes from multiple bands
            In ArcGIS 9.x Raster Catalog, you can use a syntax like this:
            [KALI-1415.jpg - Band_1] <= 50 & [KALI-1415.jpg - Band_2] >= 120 & [KALI-1415.jpg - Band_3] <= 173

            In ArcGIS 10 Raster Catalog, use full catalog path names instead of layer names in the expression.

            (("C:\Test\KALI-1415.jpg\Band_1") <= 50) & (("C:\Test\KALI-1415.jpg\Band_2") >= 120) & (("C:\Test\KALI-1415.jpg\Band_3") <= 173)

            *KALI-1415.jpg is my example image.