SARscape中的SLC配准(SLC coregistration)功能【注意,并不是coregistration功能】,界面如👇。功能界面的样子应该是可以批量配准的,但是一直没有成功,条条大路通罗马,所以决定用idl实现批量配准到同一主影像的功能
。
1.数据准备
- 本次输入数据,是镶嵌后的VV极化影像
- 存放主影像的文件夹(只有1景)
- 存放待配准影像的文件夹(1景或多景)
2.实现过程
- 准备.sml文件
在envi软件中,sarscape/preference中设置好参数,然后保存。
- 打开ENVI+IDL
- 新建文件并重命名(建议名称与2中PRO的名称一致)
- 写入代码并按照注释运行
;函数功能
;批量配准SLC影像到同一主影像
;使用方法
;0.编译本pro文件
;1.命令行初始化路径参数
;the_master_dir = 'E:\SecondInsar\3.import\path55_01';#master影像路径(单景)
;the_slave_dir = 'E:\SecondInsar\3.import\path55_02';#slave影像路径(单景或多景)
;the_output_dir = 'E:\SecondInsar\8.idl';
;the_suffix = 'VV';#影像二进制文件名识别标志
;注意:SARscape_default_values_dataset_SENTINEL_TOPSAR.sml
;可以从envi/preference中保存得到
;名称要设置一致
;要放在output_dir路径下
;2.命令行运行
;IDLscript_batch_SLCcoregistration, the_master_dir, the_slave_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_SLCcoregistration, the_master_dir, the_slave_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_master_dir) ne 0 and $
N_ELEMENTS(the_slave_dir) ne 0 and $
N_ELEMENTS(the_output_dir) ne 0 and $
N_ELEMENTS(the_suffix) ne 0) then begin
theMasterDir = the_master_dir
theSlaveDir = the_slave_dir
theOutputDir = the_output_dir
theSuffix = the_suffix
endif else begin
myResult = ROUTINE_INFO('IDLscript_batch_SLCcoregistration', /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_Master = FILE_SEARCH(theMasterDir,'*'+theSuffix);
inRasterName_Slave = FILE_SEARCH(theSlaveDir,'*'+theSuffix);
; 检查master文件数量是否为1
; 检查slave文件数量是否大于等于1
if (inRasterName_Master.length ne 1 or inRasterName_Slave.length EQ 0) then begin
myResult = ROUTINE_INFO('IDLscript_batch_SLCcoregistration', /SOURCE)
PRINT, myResult
Print,' ************************************************************* '
Print,' Numbers of InputFiles1 SHOULD be 1 !!! '
Print,' But Numbers of InputFiles1 is ' + inRasterName_Master.length
Print,' Numbers of InputFiles2 SHOULD larger than 0 !!!'
Print,' But Numbers of InputFiles2 is ' + inRasterName_Slave.length
Print,' ************************************************************* '
SARscape_Batch_Exit
return;
endif else begin
arr = [0: inRasterName_Slave.length-1]
endelse
; 逐景配准到主影像
master = inRasterName_Master[0]
foreach element,arr DO BEGIN
;检查轨道号和日期是否对应
slave = inRasterName_Slave[element]
; 6) Create the Slant Range Mosaic object
OB = obj_new('SARscapeBatch',Module='POLINSARPOLARIMETRICSLCCOREGISTRATION')
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
masterInList = [master,slave]
OB->Setparam,'input_master_file_list', [master]
OB->Setparam,'input_slave_file_list', [slave]
outRasterNameMaster = theOutputDir+PATH_SEP()+PATHPARSE(master);
outRasterNameSlave = theOutputDir+PATH_SEP()+PATHPARSE(slave);
OB->Setparam,'output_master_file_list', [outRasterNameMaster]
OB->Setparam,'output_slave_file_list', [outRasterNameSlave]
;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,'MasterFile is '+ master
Print,'SlaveFile is '+ slave
Print,'CoregistrationMasterFile is '+ outRasterNameMaster
Print,'CoregistrationSlaveFile is '+ outRasterNameSlave
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