天天看点

【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking

SARscape是强大的雷达影像处理软件,其中影像导入、影像裁剪等基本常用功能都可以进行批量处理非常方便。但是其中的同轨道影像镶嵌(Slant Range Mosaicing)功能,一次操作 只能完成一个轨道同一时间段下的影像拼接,当需要批量处理时,多次的点选以及时间的把控就很不方便。

因此,参考SARscape IDL Scripting中的example以及IDL的Help文档,实现哨兵一号的两景影像批量镶嵌。

1.数据准备

  • 待多视的影像
    【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking

2.实现过程

  1. 准备.sml文件

    在envi软件中,sarscape/preference中设置好参数,然后保存。

    【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking
  2. 打开ENVI+IDL
    【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking
  3. 新建文件并重命名(建议名称与3中PRO的名称一致)
  4. 写入代码并按照注释运行
;函数功能
;批量复数数据多视处理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

           

3. 成功运行结果

【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking
【sarscape】使用envi idl 实现哨兵一号批量ComplexDataMultilooking

继续阅读