Skip to content

DEM handler based on GDAL

Cédric Traizet requested to merge gdal_dem_handler into develop

Summary

DEMHandler class based on GDAL.

Closes #1762 (closed)

Rationale

The current otb::DEMHandler in the OSSIMAdapters module uses Ossim to manage elevation. As part of #1506 (closed), this dependency will be removed, therefore we need to implement another DEMHandler.

The new class is part of the IOGDAL module (it uses the Dataset and driverManager wrapper classes). The API is mostly the same as the current DEMHandler, with the difference that const char* parameters have been replaced by const std::string&.

In particular this classes is a singleton, it can be accessed (and instantiated) with the OTB::DEMHandler() method.

  • OpenDEMFile(file) : Open a raster dataset
  • OpenDEMDirectory(dir) : Open all raster dataset in the directory as DEM dataset
  • OpenGeoidFile(file) : Open a geoid dataset
  • SetDefaultHeightAboveEllipsoid(value) : default height in case no elevation information is available (default 0)

Several DEMs can be opened at the same time, internally, a mosaic vrt is created in this case. Elevation can be accessed with :

  • GetHeightAboveEllipsoid(lon, lat) :
    • SRTM and geoid both available: srtm_value + geoid_offset
    • No SRTM but geoid available: geoid_offset
    • SRTM available, but no geoid: srtm_value
    • No SRTM and no geoid available: default height above ellipsoid
  • GetHeightAboveMSL(lon, lat) :
    • SRTM and geoid both available: srtm_value
    • No SRTM but geoid available: 0
    • SRTM available, but no geoid: srtm_value
    • No SRTM and no geoid available: 0

Geoid and DEM files are read as raster. This means that any file that can be read as raster by GDAL can be used.

Note that the egm96.grd geoid file currently provided by OTB and Ossim cannot be accessed by this DEMHandler as it is not recognized by GDAL. A egm96.hdr file is now provided with egm96.grd with the required information to read the geoid as an ENVI file. Also note that GDAL is able to open .gtx geoid files.

The new DEMHandler should return the same results as the current one, as both classes use bilinear interpolation to compute elevation (both for DEM and geoid elevation), with the exception of no data management. If a no data is present in the bilinear 2x2 interpolation window the new class will return no data while the old class would have returned an elevation value with a null weight for the no data value in the interpolation of the heigth. This behavior has been chosen to stay coherent with how no data are handled in RPC models in GDAL (#2040 (closed)). One baseline has been modified to match this behavior (Data/Baseline/OTB/Images/ioTvDEMToImageGenerator2.1.tif).

A dependency to boost::filesystem has been added, it is used to access the name of the file in a directory (this is not in ITK system functions, and not in the standard library before C++ 17).

Additional notes

The old DEMHandler classes has not been removed yet and has been renamed into OssimDEMHandler, it is still used to setup DEM for RPC and SAR models. This class will be removed as soon as it is not needed anymore.

Acceptance criterias

Some analysis had been done between OTB 7.0 and current DEM_handler version. An orthorectification was processed and showed some small numerical differences between the resulting images. Besides, the computing time was much slower with the new code. The same kind of test must be done between 7.2 and current DEM_handler version (using some significant image, from large input dataset, or from the training dataset) : this analysis must be taken care thoroughly before we decide anything (adapt or correct code, merge it, open an other issue, etc.) Below are two acceptance criteria :

  • Precision analysis : numerical differences have to be checked before merging.
  • Computation time analysis : the impact on computation time must be evaluated

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
  • Optionally, run git diff develop... -U0 --no-color | clang-format-diff.py -p1 -i on latest changes and commit
Edited by Yannick TANGUY

Merge request reports