# SuperImpose develop behavior

**URL:** <https://forum.orfeo-toolbox.org/t/superimpose-develop-behavior/1225>\
**Category:** OTB Development\
**Created:** [January 5, 2022, 4:15pm UTC](https://forum.orfeo-toolbox.org/t/superimpose-develop-behavior/1225 "2022-01-05T16:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurV](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@ArthurV](https://forum.orfeo-toolbox.org/u/ArthurV)\
**Post date:** [January 5, 2022, 4:15pm UTC](https://forum.orfeo-toolbox.org/t/superimpose-develop-behavior/1225/1 "2022-01-05T16:15:42Z")

</div>

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

```python
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

```bash
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()`

```python
superimp_vv.Execute()
superimp_vh.Execute()

```

It works.

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

```python
.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](https://cs-share.c-s.fr/index.php/s/YS3aKXHXE77xEAa) (11Mo)

Thanks,

Arthur.

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [January 7, 2022, 2:38pm UTC](https://forum.orfeo-toolbox.org/t/superimpose-develop-behavior/1225/2 "2022-01-07T14:38:08Z")

</div>

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:

```auto
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](https://www.orfeo-toolbox.org/CookBook-develop/Supported_Sensors.html#a-note-on-the-egm96-grd-file)).

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

---

<div class="post-metadata">

**Author:** ![ArthurV](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@ArthurV](https://forum.orfeo-toolbox.org/u/ArthurV)\
**Post date:** [January 10, 2022, 8:18am UTC](https://forum.orfeo-toolbox.org/t/superimpose-develop-behavior/1225/3 "2022-01-10T08:18:51Z")

</div>

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
