SARscape是強大的雷達影像處理軟體,其中影像導入、影像裁剪等基本常用功能都可以進行批量處理非常友善。但是其中的同軌道影像鑲嵌(Slant Range Mosaicing)功能,一次操作 隻能完成一個軌道同一時間段下的影像拼接,當需要批量處理時,多次的點選以及時間的把控就很不友善。
是以,參考SARscape IDL Scripting中的example以及IDL的Help文檔,實作哨兵一号的兩景影像批量鑲嵌。
1.資料準備
- 待多視的影像
【sarscape】使用envi idl 實作哨兵一号批量ComplexDataMultilooking
2.實作過程
-
準備.sml檔案
在envi軟體中,sarscape/preference中設定好參數,然後儲存。
【sarscape】使用envi idl 實作哨兵一号批量ComplexDataMultilooking - 打開ENVI+IDL
【sarscape】使用envi idl 實作哨兵一号批量ComplexDataMultilooking - 建立檔案并重命名(建議名稱與3中PRO的名稱一緻)
- 寫入代碼并按照注釋運作
;函數功能
;批量複數資料多視處理2:1
;使用方法
;0.編譯本pro檔案
;1.指令行初始化路徑參數
;the_input_dir = 'E:\SecondInsar\3.import\path55_01';#輸入影像路徑
;the_output_dir = 'E:\SecondInsar\8.idl';#輸出影像路徑
;the_suffix = 'VV';#影像二進制檔案名識别标志
;注意:SARscape_default_values_dataset_SENTINEL_TOPSAR.sml
;可以從envi/preference中儲存得到
;名稱要設定一緻
;要放在output_dir路徑下
;2.指令行運作
;IDLscript_batch_ComplexMultilooking, the_input_dir, the_output_dir, the_suffix
FUNCTION PATHPARSE,the_Path
path = the_Path
path = STRSPLIT(path,'\',/EXTRACT)
path = path[-1]
RETURN,path
END
pro IDLscript_batch_ComplexMultilooking, the_input_dir, the_output_dir, the_suffix
compile_opt idl2
; 判斷IDL是否成功啟動
CATCH, error
if error ne 0 then begin
k = dialog_message(!error_state.msg,/ERROR)
return
endif
; 設定運作路徑
if (N_ELEMENTS(the_input_dir) ne 0 and $
N_ELEMENTS(the_output_dir) ne 0 and $
N_ELEMENTS(the_suffix) ne 0) then begin
theInputDir = the_input_dir
theOutputDir = the_output_dir
theSuffix = the_suffix
endif else begin
myResult = ROUTINE_INFO('IDLscript_batch_ComplexMultilooking', /SOURCE)
PRINT, myResult
theTestDir = FILE_DIRNAME(myResult.PATH) +PATH_SEP()+'data'
Print,' ************************************************************* '
Print,' Plz Set the Paths of InpurFiles Correctly!!! '
Print,' ************************************************************* '
SARscape_Batch_Exit
return;
endelse
; 設定臨時檔案路徑
aTmp = theOutputDir+PATH_SEP()+'temp'
FILE_MKDIR,aTmp
; 1) SARscape batch initialization and temporary directory setting
SARscape_Batch_Init,Temp_Directory=aTmp
; 設定工作路徑
aTemp = aTmp+PATH_SEP()+'step'
aWorkDir = aTemp+PATH_SEP()+'work'
FILE_MKDIR, aWorkDir
;4) Load the user-specific default file (i.e. SARscape_preferences_user.sml) optional
; 将sarscape的preference的文本文檔内容替換.sml中的内容
; D:\Program Files\SARMAP SA\SARscape 5.2\auxiliary\description_files
default_file_name = theOutputDir+PATH_SEP()+'SARscape_default_values_dataset_SENTINEL_TOPSAR.sml'
aRet = SARscape_set_save_actual_default_in_dfl (default_file_name)
IF aRet ne 'OK' THEN BEGIN
Print,' ************************************************************* '
Print,' File inconsistency ', default_file_name
Print,' ************************************************************* '
SARscape_Batch_Exit
return;
ENDIF
;5) set a working directory optional
if (SARscape_set_working_in_actual_default(aWorkDir) eq 'NotOK') then begin
ok = dialog_message('You have to initialize a valid work directory' ,/ERROR)
SARscape_Batch_Exit
RETURN
endif
aActualStep = 0
; 3) 設定輸入參數
inRasterName = FILE_SEARCH(theInputDir,'*'+theSuffix);
; 檢查檔案數量是否大于等于1
if (inRasterName.length EQ 0) then begin
myResult = ROUTINE_INFO('IDLscript_batch_ComplexMultilooking', /SOURCE)
PRINT, myResult
Print,' ************************************************************* '
Print,' Numbers of InputFiles SHOULD larger than 0 !!!'
Print,' But Numbers of InputFiles is ' + inRasterName.length
Print,' ************************************************************* '
SARscape_Batch_Exit
return;
endif else begin
arr = [0: inRasterName.length-1]
endelse
; 逐景多視
foreach element,arr DO BEGIN
;檢查軌道号和日期是否對應
input = inRasterName[element]
; 6) Create the Slant Range Mosaic object
OB = obj_new('SARscapeBatch',Module='INSARCOMPLEXDATAMULTILOOKING')
IF (~OBJ_VALID(OB)) THEN BEGIN
; The object is not valid then the user must manage the error
; Exit from SARscape batch
SARscape_Batch_Exit
return
ENDIF
;7) Fill the Parameters
OB->Setparam,'range_multilook', 2
OB->Setparam,'input_file_name', input
outRasterName = theOutputDir+PATH_SEP()+PATHPARSE(input);
OB->Setparam,'output_file_name', outRasterName
;8) Verify the parameters
ok = OB->VerifyParams(Silent=0)
IF ~ok THEN BEGIN
Print,' ************************************************************* '
Print,' Module can not be executed; Some parameters need to be filled '
Print,' ************************************************************* '
; Exit from SARscape batch
SARscape_Batch_Exit
return;
ENDIF
Print,' ************* '
Print,'inputFile is '+ input
Print,'MultilookingFile is '+ outRasterName
Print,' ************* '
;9) Process execution
OK = OB->Execute();
IF OK THEN BEGIN
Print,' ************* '
Print,'STEP Success...... '
Print,' ************* '
ENDIF else begin
aErrCode = ''
; extract the error message from error file
aOutMsg = get_SARscape_error_string('NotOK',ERROR_CODE=aErrCode)
aOutMsg = get_SARscape_error_string('OK',ERROR_CODE=aErrCode)
Print,' ************* '
Print,'STEP FAIL...... '
Print, 'ERROR CODE : '+aErrCode
Print, aOutMsg
Print,' ************* '
ENDELSE
endforeach
Print,' ************* All Tasks Success ************* '
; 10)Exit from batch procedure
SARscape_Batch_Exit
end