;+
; Author: Baikal
;-
; Time: Jan 11,2018
;
; Batching Mosaic based on ENVI/IDL.
PRO MOSAICbatch
COMPILE_OPT IDL2
; Start the application
e = ENVI()
; Select input scenes
files = FILE_SEARCH('G:\2016.06.MOD\MOD35\5Clip\', '*.tif')
Output_dir = 'G:\2016.06.MOD\MOD35\7Sea\201606\'
;将同一天待镶嵌的两幅影像移动至单独的文件夹
MV_dir = Output_dir + '\Single_Day_Double\'
scenes = !NULL
FOR i=0, N_ELEMENTS(files)-1 DO BEGIN
if i EQ 0 THEN void = READ_TIFF(files[i],GEOTIFF = geoinfo)
if i NE N_ELEMENTS(files)-1 THEN BEGIN
; FILE_MOVE,files[i],MV_dir
; FILE_MOVE,files[i+1],MV_dir
backslash_pos = strpos(files[i],'\',/reverse_search)
file_date1 = strmid(files[i],backslash_pos + 1,7)
file_date2 = strmid(files[i+1],backslash_pos + 1,7)
if file_date1 EQ file_Date2 THEN BEGIN
raster1 = e.OpenRaster(files[i])
raster2 = e.OpenRaster(files[i+1])
scenes = [raster1, raster2]
; Create the mosaic raster
mosaicRaster = ENVIMosaicRaster(scenes , BACKGROUND = !VALUES.F_NAN )
; Save it as ENVI format
newFile = e.GetTemporaryFilename()
mosaicRaster.Export, newFile, 'ENVI'
; Open the mosaic file
mosaicRaster = e.OpenRaster(newFile)
; Exportthe raster as a TIFF file.
; Change the directory as needed for your own system
SubRaster = ENVISubsetRaster(mosaicRaster)
; Display the result
View = e.GetView()
Layer = View.CreateLayer(mosaicRaster)
View.Zoom, /FULL_EXTENT
Outname = file_date1 + '_Cloud.tif'
SubRaster.Export, Output_dir + Outname , 'TIFF'
; Close the dataset and remove it from the display
raster1.Close
raster2.Close
endif
endif
ENDFOR
e.close
END
Reference:
http://www.harrisgeospatial.com/docs/ENVIMosaicRaster.html
http://www.harrisgeospatial.com/docs/programmingguideworkingwithrasters.html#VirtualRasterConsiderations
; Author: Baikal
;-
; Time: Jan 11,2018
;
; Batching Mosaic based on ENVI/IDL.
PRO MOSAICbatch
COMPILE_OPT IDL2
; Start the application
e = ENVI()
; Select input scenes
files = FILE_SEARCH('G:\2016.06.MOD\MOD35\5Clip\', '*.tif')
Output_dir = 'G:\2016.06.MOD\MOD35\7Sea\201606\'
;将同一天待镶嵌的两幅影像移动至单独的文件夹
MV_dir = Output_dir + '\Single_Day_Double\'
scenes = !NULL
FOR i=0, N_ELEMENTS(files)-1 DO BEGIN
if i EQ 0 THEN void = READ_TIFF(files[i],GEOTIFF = geoinfo)
if i NE N_ELEMENTS(files)-1 THEN BEGIN
; FILE_MOVE,files[i],MV_dir
; FILE_MOVE,files[i+1],MV_dir
backslash_pos = strpos(files[i],'\',/reverse_search)
file_date1 = strmid(files[i],backslash_pos + 1,7)
file_date2 = strmid(files[i+1],backslash_pos + 1,7)
if file_date1 EQ file_Date2 THEN BEGIN
raster1 = e.OpenRaster(files[i])
raster2 = e.OpenRaster(files[i+1])
scenes = [raster1, raster2]
; Create the mosaic raster
mosaicRaster = ENVIMosaicRaster(scenes , BACKGROUND = !VALUES.F_NAN )
; Save it as ENVI format
newFile = e.GetTemporaryFilename()
mosaicRaster.Export, newFile, 'ENVI'
; Open the mosaic file
mosaicRaster = e.OpenRaster(newFile)
; Exportthe raster as a TIFF file.
; Change the directory as needed for your own system
SubRaster = ENVISubsetRaster(mosaicRaster)
; Display the result
View = e.GetView()
Layer = View.CreateLayer(mosaicRaster)
View.Zoom, /FULL_EXTENT
Outname = file_date1 + '_Cloud.tif'
SubRaster.Export, Output_dir + Outname , 'TIFF'
; Close the dataset and remove it from the display
raster1.Close
raster2.Close
endif
endif
ENDFOR
e.close
END
Reference:
http://www.harrisgeospatial.com/docs/ENVIMosaicRaster.html
http://www.harrisgeospatial.com/docs/programmingguideworkingwithrasters.html#VirtualRasterConsiderations
没有评论:
发表评论