I have an script to transform DN into Reflectance of each band of several images. The unique variable of the equation, apart of the Band it self, is the Divisor:
Any idea?
Thanks
import os, arcpy, glob from arcpy import env, sa check = arcpy.CheckOutExtension("Spatial") print check arcpy.env.workspace = r'F:\Mosaic 2000' ws = env.workspace wsf= r'F:Mosaic 2000\Reflectance' rasters = glob.glob(os.path.join(ws,'*.tif')) for raster in rasters: try: '''bands1 = os.path.basename(raster) + '\Band_1' Refl1 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands1))- 1) / 0.0508)) outname = os.path.basename(raster)[15:23]+'_B1.tif' Refl1.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message) try: bands2 = os.path.basename(raster) + '\Band_2' Refl2 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands2))- 1) / 0.0254)) outname = os.path.basename(raster)[15:23]+'_B2.tif' Refl2.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message)''' try: bands3 = os.path.basename(raster) + '\Band_3' Refl3 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands3))- 1) / 0.0363)) outname = os.path.basename(raster)[15:23]+'_B3.tif' Refl3.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message) try: bands4 = os.path.basename(raster) + '\Band_4' Refl4 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands4))- 1) / 0.0423)) outname = os.path.basename(raster)[15:23]+'_B4.tif' Refl4.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message)
أكثر...
- (B1 - 1) / 508
- (B2 - 1) / 254
- (B3 - 1) / 363
- (B4 - 1) / 423
Any idea?
Thanks
import os, arcpy, glob from arcpy import env, sa check = arcpy.CheckOutExtension("Spatial") print check arcpy.env.workspace = r'F:\Mosaic 2000' ws = env.workspace wsf= r'F:Mosaic 2000\Reflectance' rasters = glob.glob(os.path.join(ws,'*.tif')) for raster in rasters: try: '''bands1 = os.path.basename(raster) + '\Band_1' Refl1 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands1))- 1) / 0.0508)) outname = os.path.basename(raster)[15:23]+'_B1.tif' Refl1.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message) try: bands2 = os.path.basename(raster) + '\Band_2' Refl2 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands2))- 1) / 0.0254)) outname = os.path.basename(raster)[15:23]+'_B2.tif' Refl2.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message)''' try: bands3 = os.path.basename(raster) + '\Band_3' Refl3 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands3))- 1) / 0.0363)) outname = os.path.basename(raster)[15:23]+'_B3.tif' Refl3.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message) try: bands4 = os.path.basename(raster) + '\Band_4' Refl4 = arcpy.sa.Int(arcpy.sa.Int(arcpy.sa.Int((arcpy.sa.Raster(bands4))- 1) / 0.0423)) outname = os.path.basename(raster)[15:23]+'_B4.tif' Refl4.save(os.path.join(wsf,outname)) print outname except Exception as e: arcpy.AddError(e.message)
أكثر...