[gdal-dev] Troubles in coord conversions with GDAL+proj6

Even Rouault even.rouault at spatialys.com
Sun Feb 24 05:29:24 PST 2019


Joaquim,

> 
> 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)

That one is really odd. It looks like some datum shift would be applied, which 
doesn't make sense here since your target SRS uses WGS84 too. Can you run your 
code with PROJ_DEBUG=5 and CPL_DEBUG=ON environment variables set ?

For correct results, you should see something like:
OGRCT: proj=pipeline step inv proj=utm zone=29 ellps=WGS84 step 
proj=unitconvert xy_in=rad xy_out=deg step proj=axisswap order=2,1 (Inverse of 
UTM zone 29N)


> and the other is
> that in this later case it outputs lat,long instead of lon,lat

That one is expected. SetWellKnownGeogCS( "WGS84" ) now returns a SRS with 
lat, lon order. You can force "GIS" friendly order by calling
oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list