Perl scripts: mk_geo_radcal, mk_geo_data
NAME:
mk_geo_radcal -
Terrain geocoding of SAR
images with lookup table refinement and resample DEM to SAR
Range-Doppler Coordinates (RDC) and perform pixel area correction
to derive sigma0
$ mk_geo_radcal
*** /Users/cw/gamma_software/DIFF/scripts/mk_geo_radcal
*** Copyright 2015, Gamma Remote Sensing, v5.9 17-Apr-2015 clw
***
*** Terrain geocoding of SAR images including lookup-table
refinement + resampling of the DEM to SAR Range-Doppler
Coordinates (RDC) ***
usage: /Users/cw/gamma_software/DIFF/scripts/mk_geo_radcal
<MLI> <MLI_par> <DEM> <DEM_par>
<DEM_seg> <DEM_seg_par> <GEO_dir>
<scene_id> <post> <mode> [ls_mode] [r_ovr]
[gc_n_ovr] [rad_max] [rlks] [azlks] [thres] [rpos] [azpos] [roff]
[azoff] [r_patch] [az_patch] [nr] [naz]
MLI (input)
MLI SAR image (including path)
MLI_par (input)
ISP image parameter file of the MLI image (including path)
DEM (input)
DEM in desired output projection (including path)
DEM_par (input)
DEM parameter file (including path)
DEM_seg (output)
DEM segment for output image products (including path)
DEM_seg_par (input/output) DEM parameter
file for output image products (including path), regenerated each
time
GEO_dir
directory for output images, lookup tables and DEM products
scene_id scene name to
identify output files
post output image
sample spacing in meters or degrees for geographic (EQA)
projection
mode processing
mode:
0: generate initial lookup table, simulated SAR image, and DEM
segment parameters, erase existing DEM segment parameters
1: measure initial offset between simulated SAR image and actual
SAR image
2: perform refinement of lookup table by offset measurement with
respect to the simulated SAR image
3: update lookup table and produce terrain geocoded SAR image and
DEM in SAR range-Doppler coordinates (RDC)
4: ellipsoid geocoding of the SAR image without a DEM, erase
existing DEM segment parameters
ls_mode
algorithm selection in gc_map for regions of layover, shadow, or
DEM gaps (enter - for default):
0: set to (0.,0.)
1: linear interpolation across these regions
2: use actual value (default)
3: nearest neighbour thinned (nn-thinned)
r_ovr range
over-sampling parameter for ls_mode = 3 (nn-thinned) (enter - for
default: 16)
gc_n_ovr interpolation
oversampling factor used by geocode (enter - for default: 2)
rad_max maximum
interpolation search radius used by geocode (enter - for default:
4*gc_n_ovr)
NOTE: gc_n_ovr and rad_max are parameters used
by the program geocode for transformation of the simulated
image
and DEM
into SAR geometry. The parameters rlks, azlks, thres, rpos,
azpos, roff, azoff are used
for estimation of the initial offset of
the SAR image with respected to the simulated SAR image.
rlks number of
range looks for the initial offset estimate (default: 1)
azlks number of azimuth
looks for the initial offset estimate (default: 1)
thres SNR threshold for
offset measurements over offset grid (default: 10)
rpos range
position for initial offset (enter - for default)
azpos azimuth position
for initial offset (enter - for default)
roff initial
range offset estimate (enter - for current value in DIFF_par
file)
azoff initial azimuth
offset estimate (enter - for current value in DIFF_par file)
r_patch range
patch size for offset estimation (default: 512 samples)
az_patch azimuth patch
size for offset estimation (default: 512 lines)
nr
number of range patches for offset estimation (default: 0)
naz number
of azimuth patches for offset estimation (default: 0)
-s scale (option) set
image display scale factor (default: 0.9)
-e exp
(option) set image display exponent (default: 0.4)
-b
(option) set raster image type to Sun raster format (default:
bmp)
-r
(option) use existing DEM segment to determine image bounds, do
not erase an existing DEM segment parameter file
-q
(option) quiet mode, run without displaying images on screen
-p
(option) use pixel_area program to generate simulated SAR image
in Range-Doppler Coordinates (RDC)
NOTE: ls_mode must equal actual area: 2
-j
(option) do not use layover-shadow map in pixel_area
calculation
-i map_pwr (option) intensity
image in map coordinates to be used for lookup table
refinement
instead of a simulated SAR image, same geometry as DEM_seg
-c
(option) calculate radiometrically calibrated radar backscatter
image
-d
(option) resample DEM to Range-Doppler Coordinates (RDC)
-x psize (option)
image patch size for initial offset estimate using
cross-correlation in mode 1 (default: 1024)
-h
(option) reference height for ellipsoid geocoding, mode 4
(default: 100)
-t thres2 (option) SNR
threshold for initial offset estimate (default: 8)
-n npoly (option)
number of terms in the range and azimuth offset polynomials
(default: 1)
-o n_ovr (option)
offset estimation oversampling factor for image data (default:
2)
mk_geo_radcal mli_1_4/20080806_HH.mli
mli_1_4/20080806_HH.mli.par DEM/katmai.dem DEM/katmai.dem_par
geo/kt.dem geo/kt.dem_par geo kt 1.851852e-4 0 2 -s .7 -e .35 -p
-c -d
$ more katmai.dem_par
Gamma DIFF&GEO DEM/MAP parameter file
title: SRTM Katmai 3 arc-sec
DEM_projection: EQA
data_format:
INTEGER*2
DEM_hgt_offset:
0.00000
DEM_scale:
1.00000
width:
12000
nlines:
6000
corner_lat: 60.0000000 decimal
degrees
corner_lon: -160.0000000 decimal degrees
post_lat: -8.3333333e-04 decimal degrees
post_lon: 8.3333333e-04 decimal
degrees
ellipsoid_name: WGS 84
ellipsoid_ra:
6378137.000 m
ellipsoid_reciprocal_flattening: 298.2572236
datum_name: WGS 1984
datum_shift_dx:
0.000 m
datum_shift_dy:
0.000 m
datum_shift_dz:
0.000 m
datum_scale_m:
0.00000e+00
datum_rotation_alpha: 0.00000e+00 arc-sec
datum_rotation_beta: 0.00000e+00
arc-sec
datum_rotation_gamma: 0.00000e+00 arc-sec
datum_country_list Global Definition, WGS84, World
rasshd katmai.dem 12000 30 30 1 0 3 3 - - 1
katmai.dem.ras 1
disdem_par
katmai.dem
katmai.dem_par
The first step is generate the look up table to
geocode the input image mli_1_4/20080806_HH.mli with parameter
file mli_1_4/20080806_HH.mli.par using the DEM data in
DEM/katmai.dem with the parameter file geo/kt.dem_par. The
program pixel_area is used to calculate the simulated radar image
in slant range coordaintes kt_0.pix using the layover-shadow map,
lookup table, and incidence angle map. The script then displays
both the simulated radar image and the actual radar image.
mk_geo_radcal mli_1_4/20080806_HH.mli
mli_1_4/20080806_HH.mli.par DEM/katmai.dem DEM/katmai.dem_par
geo/kt.dem geo/kt.dem_par geo kt 1.851852e-4 0 2 -s .7 -e .35 -p
-c -d
The section of the the DEM
covering the SAR image is resampled to -1.8518520e-04
degrees (~20m) and stored in the file kt.dem with parameter file
kt.dem_par.gc_map mli_1_4/20080806_HH.mli.par - DEM/katmai.dem_par
DEM/katmai.dem geo/kt.dem_par geo/kt.dem geo/kt_0.map_to_rdc
4.49999962200003 4.49999962200003 geo/kt_0.sim - -
geo/kt_0.inc_map - geo/kt_0.pix_map geo/kt_0.ls_map 32 2 16
The DEM segment dimensions and sample spacing is
determined by gc_map and stored in the DEM segment parameter
file, in this cast kt.dem_par:
Gamma DIFF&GEO DEM/MAP parameter file
title: srtm_06_01
DEM_projection: EQA
data_format: REAL*4
DEM_hgt_offset:
0.00000
DEM_scale:
1.00000
width:
8770
nlines:
5845
corner_lat: 58.8516667 decimal
degrees
corner_lon: -155.3466667 decimal degrees
post_lat: -1.8518520e-04 decimal degrees
post_lon: 1.8518520e-04 decimal
degrees
ellipsoid_name: WGS 84
ellipsoid_ra:
6378137.000 m
ellipsoid_reciprocal_flattening: 298.2572236
datum_name: WGS 1984
datum_shift_dx:
0.000 m
datum_shift_dy:
0.000 m
datum_shift_dz:
0.000 m
datum_scale_m:
0.00000e+00
datum_rotation_alpha: 0.00000e+00 arc-sec
datum_rotation_beta: 0.00000e+00
arc-sec
datum_rotation_gamma: 0.00000e+00 arc-sec
datum_country_list Global Definition, WGS84, World
Next calculate pixel area in slant-range coordinates
using pixel_area and display the result. If the -q option has been set, then the
display is bypassed
pixel_area mli_1_4/20080806_HH.mli.par geo/kt.dem_par geo/kt.dem
geo/kt_0.map_to_rdc geo/kt_0.ls_map geo/kt_0.inc_map
geo/kt_0.pix
raspwr geo/kt_0.pix 4968 1 0 1 1 1. .5 1
geo/kt_0.pix.ras
dis2ras geo/kt_0.pix.ras
mli_1_4/20080806_HH.mli.ras&
You
will see a display window pop up with the simulated image and the
SAR image together. You can switch display between the images
using the center mouse button.Mode 1: Estimate initial offset between the
actual and simulated SAR images and refine the
l
ookup table
mk_geo_radcal
mli_1_4/20080806_HH.mli mli_1_4/20080806_HH.mli.par
DEM/katmai.dem DEM/katmai.dem_par geo/kt.dem geo/kt.dem_par geo
kt 1.851852e-4 1 2 -s .7 -e .35 -p -c -d
rlks number of
range looks for the initial offset estimate (default: 1)
azlks number of azimuth looks
for the initial offset estimate (default: 1)
thres SNR threshold for
offset estimates (default: 10)
rpos range position for
initial offset (enter - for default)
azpos azimuth position for initial
offset (enter - for default)
roff initial range offset
estimate (enter - for current value in DIFF_par file)
azoff initial azimuth offset
estimate (enter - for current value in DIFF_par file)
The commands executed by mode 1 are first to create
the DIFF_par parameter file that holds the offset model for
geocoding refinement, followed by init_offsetm determine the
initial offset between the simulated SAR image and the actual
image#create DIFF_par parameter file to save the offset
parameters:
create_diff_par mli_1_4/20080806_HH.mli.par - geo/kt.diff_par 1
< geo/kt.diff_par.in
The file kt.diff_par.in contains inputs for create_diff_par.
#measure offset for a single large patch
init_offsetm geo/kt_0.pix mli_1_4/20080806_HH.mli geo/kt.diff_par
3 3 2484 4065.5 0 0 10 1024 1
initial range offset (samples): -2.68825 azimuth
offset (lines): -5.67973
setting range and azimuth offset polynomial values to initial
offsets in file: geo/kt.diff_par
$ mk_geo_radcal
mli_1_4/20080806_HH.mli mli_1_4/20080806_HH.mli.par
DEM/katmai.dem DEM/katmai.dem_par geo/kt.dem geo/kt.dem_par geo
kt 1.851852e-4 2 2 -s .7 -e .35 -p -c -d
Note that many cases it is sufficient for getting an
accurate scene geocoding only to measure this one offset and go
directly to mode 3. In some images with very few features there
are only a few areas in the scene that can be used for measuring
the offset. In that case, do not run mode 2 of mk_geo_radcal. Enter the center of
this area on the command line in the MLI pixel coordinates for
mode 1 and go directly to mode 3. Running mk_geo_radcal mode 2 will estimate
the offsets over the entire scene using image patches (512x512)
on a grid. The patch size can be changed using the
r_patch and az_patch parameters. The
program offset_pwrm measures the
offsets over the entire scene and offset_fitm calculates the range and
azimuth offset polynomials from the offset measurements and
signal to noise ratio (SNR) of the measurements:#measure offsets of intensity images
offset_pwrm geo/lan_0.sim_rdc rmli_2_10/rmli_2_10.ave
geo/lan.diff geo/lan.offs geo/lan.snr
#calculate range and azimuth offset polynomials with 3 terms
each
offset_fitm geo/lan.offs geo/lan.snr geo/lan.diff geo/lan.coffs -
10 3
In a few cases with sparse dem data or images with no
contrast, it may not be possible to find enough points to
estimate the offset polynomial parameters. In this case, select a
single area in the image with some features and that are also
visible in the simulated SAR image. Determine the coordinates of
this point in the SAR image and then run mode 2 above specifying
the coordinates with rpos and azpos command line parameters. The
initial offset values are written as the constant values of
offset polynomials. This should usually be sufficient to geocode
the image and you can omit running Mode 2.$ more kt.diff_par
Gamma DIFF&GEO Processing Parameters
title: kt
initial_range_offset:
-3
initial_azimuth_offset:
-6
range_samp_1:
4968
az_samp_1:
8131
first_nonzero_range_pixel_1:
0
number_of_nonzero_range_pixels_1:
4968
range_pixel_spacing_1:
9.368514
az_pixel_spacing_1:
12.577748
range_samp_2:
4968
az_samp_2:
8131
first_nonzero_range_pixel_2:
0
number_of_nonzero_range_pixels_2:
4968
range_pixel_spacing_2:
9.368514
az_pixel_spacing_2:
12.577748
offset_estimation_starting_range:
48
offset_estimation_ending_range:
4920
offset_estimation_range_samples:
20
offset_estimation_range_spacing:
256
offset_estimation_starting_azimuth:
48
offset_estimation_ending_azimuth:
8083
offset_estimation_azimuth_samples:
20
offset_estimation_azimuth_spacing:
422
offset_estimation_patch_width:
512
offset_estimation_patch_height:
512
offset_estimation_threshhold:
10.00
range_offset_polynomial:
-2.41406 8.2933e-06
-7.3133e-05 0.0000e+00
0.0000e+00 0.0000e+00
azimuth_offset_polynomial:
-5.98119 -4.4024e-05
4.7028e-06 0.0000e+00
0.0000e+00 0.0000e+00
starting_azimuth_line:
0
map_azimuth_lines:
0
map_width:
0
first_map_range_pixel:
0
number_map_range_pixels:
0
range_looks:
0
azimuth_looks:
0
diff_phase_fit:
0.00000 0.0000e+00
0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00
mk_geo_radcal mli_1_4/20080806_HH.mli
mli_1_4/20080806_HH.mli.par DEM/katmai.dem DEM/katmai.dem_par
geo/kt.dem geo/kt.dem_par geo kt 1.851852e-4 3 2 -s .7 -e .35 -p
-c -d
#update the geocoding lookup table using
gc_map_fine:
gc_map_fine geo/kt_0.map_to_rdc 8770 geo/kt.diff_par
geo/kt_1.map_to_rdc 1
#pixel area correction factor calculated using the refined lookup
table, layover-shadow map, and incidence angle map:
pixel_area mli_1_4/20080806_HH.mli.par geo/kt.dem_par
geo/kt.dem geo/kt_1.map_to_rdc geo/kt_0.ls_map geo/kt_0.inc_map
geo/kt_1.pix
raspwr geo/kt_1.pix 4968 1 0 1 1 1. .5 1
geo/kt_1.pix.ras
#resample the DEM into radar range-doppler coordiantes:
geocode geo/kt_1.map_to_rdc geo/kt.dem 8770 geo/kt_dem.rdc 4968
8131 2 0 1 1 2 8
rashgt geo/kt_dem.rdc geo/kt_1.pix 4968 1 1 0 1 1 100 1. .35 1
geo/kt_dem.rdc.ras
#display the simulated SAR image and the actual SAR image:
dis2ras geo/kt_1.pix.ras mli_1_4/20080806_HH.mli.ras&
#geocode the backscatter radar image by resampling the SAR image
into the map projection geometry:
geocode_back mli_1_4/20080806_HH.mli 4968 geo/kt_1.map_to_rdc
geo/kt_map.mli 8770 5845 2 0
raspwr geo/kt_map.mli 8770 1 0 1 1 .7 .35 1
geo/kt_map.mli.ras
#generate ellipse corrected sigma0 image from the input radar
image proportional to beta0:
radcal_MLI mli_1_4/20080806_HH.mli mli_1_4/20080806_HH.mli.par -
mli_1_4/20080806_HH.mli.ellipse_cal - 0 0 1 0.0 -
geo/kt.pix_ellipse
#perform ratio between pixel area ellipsoidal pixel area
corection factor and the pixel area correction factor determined
from the DEM:
ratio geo/kt.pix_ellipse geo/kt_1.pix geo/kt.ratio_sigma0
4968 1 1
#multiply the radar backstatter image by this ratio:
product mli_1_4/20080806_HH.mli geo/kt.ratio_sigma0
geo/kt.pix_cal 4968 1 1
#terrain geocode the pixel-area compensated backscatter
image:
geocode_back geo/kt.pix_cal 4968 geo/kt_1.map_to_rdc
geo/kt_cal_map.mli 8770 5845 2 0
raspwr geo/kt_cal_map.mli 8770 1 0 1 1 .7 .35 1
geo/kt_cal_map.mli.ras
#generate geotiff output image product
data2geotiff geo/kt.dem_par geo/kt_cal_map.mli 2
geo/kt_cal_map.mli.tif
disras_dem_par geo/kt_cal_map.mli.ras
geo/kt.dem_par&
The MLI_par is used to define the
dimensions of the SAR data set. This data set may be an
interferometric product such as a deformation map. Also required
is the lookup table that has been updated by gc_map_fine to
account for geocoding location errors. The user can specify the
interpolation mode and data format. Further documentation on
these parameters is in the DIFF/GEO documentation of geocode_back. For example to
geocode a complex format differential interferogram in RDC into
EQAmk_geo_data
mli_1_4/20080806_HH.mli.par
geo/kt.dem_par
geo/kt_1.map_to_rdc
diff0_orb/20080806_HH_20080921_HH.diff
diff0_orb/20080806_HH_20080921_HH_eqa.diff
1 1
mk_geo_data.log
#terrain geocode the complex differential interferogram using
geocode_back:
geocode_back diff0_orb/20080806_HH_20080921_HH.diff 4968
geo/kt_1.map_to_rdc diff0_orb/20080806_HH_20080921_HH_eqa.diff
8770 5845 1 1