I am trying to figure out how to do a vertical transformation using the GDAL API. In my case I'm using a C# wrapper for the GDAL API, but if answers are given in C++ or python I should be able to translate that into my project.
As an example, if I have a point in WGS84 with ellipsoid altitude at 40N, 95W, -31.82 m, then according to this site https://www.unavco.org/software/geodetic-utilities/geoid-height-calculator/geoid-height-calculator.html the orthometric height should be around 0 m.
In the GDAL API this is how I'm setting it up.
var sourceCRS = new OSGeo.OSR.SpatialReference("");
sourceCRS.ImportFromEPSG(4979); // WGS84, but specifically 3D with ellipsoidal height defined as the Z axis.
var destinationCRS = new OSGeo.OSR.SpatialReference("");
destinationCRS.ImportFromEPSG(5498); // NAD83 + NAVD88 in meters
var transformation = new OSGeo.OSR.CoordinateTransformation(sourceCRS, destinationCRS);
var point = new double[]{40, -95, -31.82};
transformation.TransformPoint(point);
After the transform, I would expect the Z value in point[2] to be close to 0, but instead the Z value is just getting passed through and is still -31.82
I've also tried using a PROJ string to setup the destination CRS like below and I downloaded the gtx files to the share directory in the GDAL folder, but this resulted in the same transformation and the Z value was just passed through as -31.82
var destinationCRS = new OSGeo.OSR.SpatialReference("");
destinationCRS.ImportFromProj4("+proj=longlat +datum=NAD83 +vunits=m +no_defs +type=crs +geoidsgrid=g2012a_conus.gtx");