[PROJ] About unit conversion
José Luis García Pallero
jgpallero at gmail.com
Mon May 18 14:03:02 PDT 2020
Hello:
I'm trying to do dome projections (forward and inverse) using the
function proj_trans_generic() and parameter string in PROJ format (+
style) and I'm a bit confused about unit conversions. My reference for
the syntax is https://proj.org/operations/conversions/unitconvert.html
For the forward problem I write
C = proj_context_create();
projection = proj_create(C,param);
proj_trans_generic(projection,PJ_FWD,lon,sizeof(double),nElem,lat,sizeof(double),nElem,NULL,0,0,NULL,0,0);
I've used the param string
'+proj=pipeline +step +proj=unitconvert +xy_in=deg +step +proj=utm
+lon_0=3w +ellps=GRS80 +step +proj=unitconvert +xy_out=km'
which means that the input coordinates are in degrees and the output
in kilometers. All works right. The results are the same if I pass the
input coordinates in radians and I use the param string
'+proj=pipeline +step +proj=utm +lon_0=3w +ellps=GRS80 +step
+proj=unitconvert +xy_out=km'
The problem comes when I try to do the inverse step. The procedure is the same:
C = proj_context_create();
projection = proj_create(C,param);
proj_trans_generic(projection,PJ_INV,x,sizeof(double),nElem,y,sizeof(double),nElem,NULL,0,0,NULL,0,0);
In the input xoordinates are in meters and I use the param string
'+proj=utm +lon_0=3w +ellps=GRS80'
The resulting longtude and latitude are correct and the units are
radians. But if I use the param string
'+proj=pipeline +step +proj=utm +lon_0=3w +ellps=GRS80 +step
+proj=unitconvert +xy_out=deg'
The output is totally wrong. I expect degrees, but the values have no
sense. Also, if I use the input X and Y in kilometers ans the param
string is
'+proj=pipeline +step +proj=unitconvert +xy_in=km +step +proj=utm
+lon_0=3w +ellps=GRS80'
the result is wrong again.
I suppose I'm doing something wrong with unit conversion, but I can not find it
Can someone help me?
Thanks
--
*****************************************
José Luis García Pallero
jgpallero at gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************
More information about the PROJ
mailing list