0

I need some assistance in determining why the following code is not re-projecting the elevation parameter. It works perfectly for the Latitude and Longitude portions but seems to completely ignore the Z parameter that's being passed in.

GDALAllRegister();

OGRSpatialReference srFrom;
srFrom.SetProjCS("WGS 84 / UTM zone 33N");
srFrom.SetWellKnownGeogCS("EPSG:32633");
srFrom.SetUTM(33,TRUE);
auto srFrome = CPLGetLastErrorMsg();

if (!std::string(srFrome).empty())
{
    auto p = "";
}


OGRSpatialReference srTo;
srTo.SetWellKnownGeogCS("EPSG:4326");
auto srToe = CPLGetLastErrorMsg();

OGRCoordinateTransformation* coordTrans = 
OGRCreateCoordinateTransformation(&srFrom, &srTo);
auto cte = CPLGetLastErrorMsg();

double x1 = 1291784.057793292;
double y1 = 2724159.114436987;
double z1 = 453.896;

int reprojected = coordTrans->Transform(1,&x1,&y1,&z1);

//Z always returns the original value passed in.
  • 1
    Why do you expect the Z is going to be reprojected? Without being a specialist, I am tempting to say that the Z value reffer to an elevation reference system that is completely independent of the coordinate system. – Marco Jan 30 '18 at 16:27
  • @Marco Your right, I suppose I have no basis to assume the value should be any different. I am no expert either which is kind of why I was asking... :) – Josh Jan 30 '18 at 16:32
  • There is some support for vertical datums in GDAL but neither EPSG:32633 nor EPSG:4326 has the vertical component so your results are expected. Read for example liblas.org/development/rfc/rfc_1_verticalcs.html and make a search "GDAL vertical datum" for finding more to read. – user30184 Jan 30 '18 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.