SuperImpose develop behavior

Hi OTB team !

I’m trying to use the actual develop branch but I’m facing a strange behavior with the Superimpose application.

Here is my code snippet

import otbApplication as otb
srtm_dir = "./SRTM"
geoid_file = "./egm96.grd"
ref_raster = "SENTINEL2B_20200101-000000-000_L2A_T31TCJ_D_V1-7_FRE_STACK.tif"
vv_raster = "s1a-iw-grd-vv-20170519t174702-20170519t174727-016654-01ba3e-001.tiff"
vh_raster = "s1a-iw-grd-vh-20170519t174702-20170519t174727-016654-01ba3e-002.tiff"

cal_vv = otb.Registry.CreateApplication("SARCalibration")
cal_vv.SetParameterString("in", vv_raster)
cal_vv.SetParameterString("lut", "gamma")
cal_vv.Execute()

cal_vh = otb.Registry.CreateApplication("SARCalibration")
cal_vh.SetParameterString("in", vh_raster)
cal_vh.SetParameterString("lut", "gamma")
cal_vh.Execute()

superimp_vv = otb.Registry.CreateApplication("Superimpose")
superimp_vv.SetParameterInputImage("inm",
                                   cal_vv.GetParameterOutputImage("out"))
superimp_vv.SetParameterString("inr", ref_raster)
superimp_vv.SetParameterString("elev.dem", srtm_dir)
superimp_vv.SetParameterString("elev.geoid", geoid_file)

superimp_vh = otb.Registry.CreateApplication("Superimpose")
superimp_vh.SetParameterInputImage("inm",
                                   cal_vv.GetParameterOutputImage("out"))
superimp_vh.SetParameterString("inr", ref_raster)
superimp_vh.SetParameterString("elev.dem", srtm_dir)
superimp_vh.SetParameterString("elev.geoid", geoid_file)

superimp_vv.Execute()
superimp_vh.Execute()

this code return the following error

ERROR 10: Pointer 'hDS' is NULL in 'GDALGetProjectionRef'.

ERROR 10: Pointer 'hSrcDS' is NULL in 'GDALCreateWarpedVRT'.

Erreur de segmentation (core dumped)

However if I remove one of these Execute()

superimp_vv.Execute()
superimp_vh.Execute()

It works.

Furthermore, without removing one of the two Execute() if I delete the two lines containing

.SetParameterString("elev.geoid", geoid_file)

It works again. Is something wrong with the elev.geoid parameter ?
I’m using the last otb develop branch to build my own conda package, maybe the issue comes from my build. EDIT : It has been reproduced with OTB 8.0 binaries.
Are you able to reproduce this issue ? All the data needed to reproduce the issue are into the archive (11Mo)

Thanks,

Arthur.

Hello,

First of all it should noted that as DEM are managed by a singleton in OTB, setting elevation parameters in an application will affect the elevation parameters of all applications.

the main problem here is that OTB 8.0 is not able to open the input egm96 file. because GDAL is used internally to open this file, it should be in a format supported by GDAL. It can be opened by the ENVI driver if the following egm96.grd.hdr is placed next to the grd file:

ENVI
samples = 1441
lines   = 721
bands   = 1
header offset = 24
file type = ENVI Standard
data type = 4
interleave = bsq
sensor type = Unknown
byte order = 1
wavelength units = Unknown
map info = {Geographic Lat/Lon, 1, 1,-0.125, 90.125, 0.25, 0.25,WGS-84}
coordinate system string = {GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]}
band names = {
Band 1}

(see this section).

However your script highlight some things that could be improved in the DEMHandler:

  • If the geoid file cannot be opened, a Warning message should be displayed
  • If a DEM has been previously opened (here in superimp_vv), opening another geoid (in superimp_vh) results in a crash because the DEMHandler tries to use the null dataset of the geoid. Instead the DEMHandler should not try to use the geoid if it cannot be opened.

Cédric

3 Likes

I didn’t spot the documentation about it in OTB’s documentation. Indeed, by placing the file egm96.grd.hdr next to egm96.grd it works !
Thanks,

Arthur