I have a raster with 4 bands. I would like to create a new raster (its individual bands called new_band) from this raster (its individual bands called old_band) in with :new_band1 = old_band1* 2new_band2= old_band2*4new_band3= old_band3*6new_band4 = old_band4*8
import sys, os, math, timeimport arcpyfrom arcpy import envfrom arcpy.sa import *arcpy.CheckOutExtension("spatial")raster = r"D:\IMAGERY.tif"bands = [['band1', 2], ['band2',4],['band3',6], ['band4', 8]]outfolder =r"D:\Radiance"for band in bands: num = band[0][4:] thisBand = raster + '\\band_' + num Radiance = arcpy.sa.Float(Raster(thisBand)/float(band[1])) outname = 'B' + num + '.tif' Radiance.save(os.path.join(outfolder,outname))#and then combine different bands arcpy.CompositeBands_management("D:\Radiance\B1.tif;D:\Radiance\B2.tif;D:\Radiance\B3.tif;D:\Radiance\B4.tif", "D:\CANGIO\Anh_SOPT5\Radiance\compbands.tif")In this colde, I created both images for individual bands and a new raster. As I just would like to create a new raster file, not rasters of individual bands, how can I do this?
أكثر...
import sys, os, math, timeimport arcpyfrom arcpy import envfrom arcpy.sa import *arcpy.CheckOutExtension("spatial")raster = r"D:\IMAGERY.tif"bands = [['band1', 2], ['band2',4],['band3',6], ['band4', 8]]outfolder =r"D:\Radiance"for band in bands: num = band[0][4:] thisBand = raster + '\\band_' + num Radiance = arcpy.sa.Float(Raster(thisBand)/float(band[1])) outname = 'B' + num + '.tif' Radiance.save(os.path.join(outfolder,outname))#and then combine different bands arcpy.CompositeBands_management("D:\Radiance\B1.tif;D:\Radiance\B2.tif;D:\Radiance\B3.tif;D:\Radiance\B4.tif", "D:\CANGIO\Anh_SOPT5\Radiance\compbands.tif")In this colde, I created both images for individual bands and a new raster. As I just would like to create a new raster file, not rasters of individual bands, how can I do this?
أكثر...