DEM handler based on GDAL
DEMHandler class based on GDAL.
otb::DEMHandler in the
OSSIMAdapters module uses Ossim to manage elevation. As part of #1506, 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
In particular this classes is a singleton, it can be accessed (and instantiated) with the
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). One baseline has been modified to match this behavior (
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).
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.
This currently does not handle the case where a DEM directory contains DEMs with different pixel type. Internally, the DEMHandler creates a vrt mosaic of all input DEMs, but different input types are not supported in gdal vrts. A solution would be to create one vrt per input type, and try to read a height value on each vrt.
There are tests failing on diapotb because of the new DEMHandler, we need to investigate why and fix it.
It has been proposed to change the behavior of the DEM handler when a DEM is available but no geoid is, currently it returns the DEM height but it could return the sum of the DEM height and the default height above ellipsoid instead. This can be done in another MR.
The DEMHandler performs one rasterIO on a 2x2 window (for interpolation) call for each height request. It could be optimized to call rasterIO on a bigger window to take advantage of GDAL caching, like it is done in the RPC module of GDAL. This can be done in another merge request.
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 -ion latest changes and commit