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?
Answer
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.
No comments:
Post a Comment