Sarscape Geocoding example script
Anonym
SARScape 5.x allows a user to execute processing steps using scripting with IDL and SARScape-specific routines. The below program is an example script for geocoding an SLC dataset.
;--------------------------------------------------------------------------------------------------
pro IDLscript_example_geocoding
compile_opt idl2
CATCH, error
if error ne 0 then begin
if n_elements(tlb) eq 1 then widget_control, tlb,/DESTROY
k = dialog_message(!error_state.msg,/ERROR)
return
endif
; 1) SARscape batch initialization and temporary directory setting
SARscape_Batch_Init,Temp_Directory='C:\temp'
; 2) Load the user-specific default file (i.e. user_default.txt) optional
default_file_name = 'C:\env\user_default.txt'
aRet = SARscape_dialog_load_xml_default (DEFAULT_FILE_NAME=default_file_name)
IF aRet eq 'NotOK' THEN BEGIN
Print,' ************************************************************* '
Print,' File inconsistency ', default_file_name
Print,' ************************************************************* '
SARscape_Batch_Exit
return;
ENDIF
; 3) Set the working directory (optional)
aWorkDir = 'C:\env\work_new'
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
; 4a)Show all SARscape functions (optional)
(obj_new('SARscapeBatch'))->Manifest
; 4b)Show specific SARscape functions (optional)
(obj_new('SARscapeBatch'))->SearchModule,'Geo'
;*************************************************************************************
;* STEP 1 GEOCODING OK
;*************************************************************************************
; Geocoding input data and parameters
inRasterName_data = 'C:\InSAR\DORIS\7_11_02_slc';
inRasterName_data2 = 'C:\InSAR\DORIS\16_01_03_slc';
inRasterName_dem = 'C:\InSAR\DORIS\start_dem';
outRasterName = 'C:\InSAR\results\7_11_02_slc_geo';
outRasterName2 = 'C:\InSAR\results\16_01_03_slc_geo';
theGridSize = 25.0
ResamplingMethod = 'optimal_resolution'
; Create the BasicGeocoding object
OB = obj_new('SARscapeBatch',Module='BasicGeocoding')
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
; Show the actual parameters
OB->ListParams
; Get the parameter type
ok = oB->_GetParamType('geocode_resampling_type', type,list)
IF ok THEN BEGIN
print,type ;
print,list ;
aSize = N_ELEMENTS(list)
print,'ELEMENTS = ', aSize
FOR i=0,aSize-1 DO BEGIN
print,'VALE['+strcompress(string(i+1),/remove_all)+'] = ['+list[i]+']' ;
endfor
ENDIF
; Fill the Parameters
aInList = [inRasterName_data]
aInList = [aInList,inRasterName_data2]
OB->Setparam,'input_file_list', aInList
aOutList = [outRasterName]
aOutList = [aOutList,outRasterName2]
OB->Setparam,'output_file_list', aOutList
OB->Setparam,'dem_file_name', inRasterName_dem
OB->Setparam,'geocode_grid_size_y', strcompress(string(theGridSize),/remove_all)
OB->Setparam,'geocode_grid_size_x', strcompress(string(theGridSize),/remove_all)
OB->Setparam,'geocode_resampling_type', ResamplingMethod
ok = oB->_GetParamType('xxxxx',type,list)
IF ok THEN BEGIN
print,type ;
print,list ;
ENDIF
; 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
; execute the process
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
; Exit from SARscape batch
SARscape_Batch_Exit
end
;------------------------------------------------------------------------------------------------------