[gdal-dev] Troubles in coord conversions with GDAL+proj6
Joaquim Manuel Freire Luís
jluis at ualg.pt
Sun Feb 24 05:05:26 PST 2019
Hi Even,
I'm having troubles migrating some of my Matlab mex to recent GDAL (built yesterday from git).
With older GDAL versions all went well. For example, this is correct
>> prj.SrcProjSRS = '+proj=utm +zone=29 +datum=WGS84 +units=m +no_defs';
>> xy = ogrproj([0 0], prj)
xy =
-13.488743884387196 0
But with newest version I'm having two problems
>> prj.SrcProjSRS = '+proj=utm +zone=29 +datum=WGS84 +units=m +no_defs';
>> xy = ogrproj([0 0], prj)
xy =
-0.000121660050290 -13.488743885487231
One is that coordinates are not correct (lat should be 0.0) and the other is that in this later case it outputs lat,long instead of lon,lat
When I run the same transformation with the command line gdaltransform I get the exact same thing with older and new GDAL builds
gdaltransform -s_srs "+proj=utm +zone=29 +datum=WGS84 +units=m +no_defs" -t_srs "+proj=longlat"
0 0
-13.4887438843872 0 0
The ogrproj is not complex and the relevant bit happen after
https://github.com/joa-quim/mirone/blob/master/mex/ogrproj.cpp#L155
I can solve the lat,lon vs lon,lat issue but am more puzzled on why the coordinates are now in error.
In another test I explicitly set the destination and now I get lon,lat but the numbers are different again (this makes no difference with the older GDAL)
>> prj.DstProjSRS = '+proj=longlat +datum=WGS84 +units=m +no_defs';
>> xy = ogrproj([0 0], prj)
xy =
-13.488864731071464 -0.000000000000010
Note that I made sure that , GDAL_DATA & PROJ_LIB are pointing to the right dirs.
>> dos('set | grep PROJ_LIB')
PROJ_LIB=C:\programs\compa_libs\proj5_GIT\compileds\VC14_64\share\proj
>> dos('set | grep GDAL_DATA')
GDAL_DATA=C:\programs\compa_libs\gdal_GIT\gdal\data
Joaquim
More information about the gdal-dev
mailing list