3

I am interested in looping through a directory and listing only the red bands (Band 1) from 4-band NAIP imagery. From there I would like to mosaic all of the band 1 layers into a new single band raster image using Mosaic to New Raster. Is there a way to specify band 1 using arcpy.ListRasters() or should I find a new approach?

6

Try this:

import os
import arcpy
bands = []
arcpy.env.workspace = #Set path to dir
for r in arcpy.ListRasters():
    rObject = arcpy.Describe(r)
    band1 = os.path.join(rObject.catalogPath,"bandx") #bandx = name of band to extract
    #outR = # full path to output raster
    #arcpy.CompositeBands_management(band1,outR) 
    bands.append(band1)

#do mosaic here outside loop.

The Composite Bands tool allows you to pull out bands from a multi band image.

  • 1
    +1 Excellent script help here--thanks. Do you know if there is any way to bypass generating Composite Bands and pass a band1 list directly to Mosaic to New Raster? – Aaron Jul 25 '13 at 20:25
  • 1
    @Aaron - instead of appending outR to the bands list, append band1 - this should give you a list of all Band1s, which you should be able to pass to the mosaic tool. – Nxaunxau Jul 25 '13 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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