<div dir="ltr">We occasionally receive datasets that have height values in feet and only specify a 2D CRS. It seems that recent versions of proj/gdal (6.3.0/3.0.3) promote to 3D by assuming the z-axis is meters rather than inferring the height units from other components. Earlier versions would infer the units as feet which was what we expected for those datasets.<div><br></div><div>I want to confirm if this change is intentional. I'm guessing that it is and that promoting 2D to 3D is not a simple problem. Nevertheless does anyone have a workaround that infers the expected vertical units from the 2D CRS most of the time?</div><div><br></div><div>I'm using the gdal C++ api and inferring the height units from the 2D CRS's linear units. I haven't tried building this exact snippet so there may be compiler errors, but it gives the general idea.</div><div><br></div><div>            int inputEpsg = 2263;</div><div>            int outputEpsg = 4979;</div><div>            double x = 1002759.79006824;</div><div>            double y = 220148.669988647;</div><div>            double z = 1797.1066;</div><div>            double expectedHeight = 547.759;</div><div><br>            OGRSpatialReference inputSpatialReference;<br>            inputSpatialReference.importFromEPSG(inputEpsg);<br>            inputSpatialReference.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);<br><br>            // Guess the units of the vertical axis for 2D CRS<br>            double verticalToMeters = 1.0;<br>            int axesCount = inputSpatialReference.GetAxesCount();<br>            if (axesCount == 2)<br>            {<br>                verticalToMeters = inputSpatialReference.GetLinearUnits();<br>            }<br><br>            OGRSpatialReference outputSpatialReference;<br>            outputSpatialReference.importFromEPSG(outputEpsg);<br>            outputSpatialReference.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);<br><br>            OGRCoordinateTransformation* transformation = OGRCreateCoordinateTransformation(&inputSpatialReference, &outputSpatialReference);<br></div><div>            transformation->Transform(1, &x, &y, &z);</div><div><br></div><div>            z *= verticalToMeters;</div><div>            assert(z == expectedHeight);</div><div><br></div><div>Is there a cleaner way for me to achieve what I want to do in the gdal C++ API? Is inferring the height units from the 2D CRS linear units generally an ok approach?<br></div><div><br></div><div>Thanks,</div><div>Sean</div></div>