[Proj] WGS84 to Sphere Inconsistency Between Proj Versions
fanslow at eos.ubc.ca
Thu Aug 21 21:51:12 EDT 2008
Thanks for looking at this. Looks like your proj reprojection matches my
result, which is encouraging. Would you go out on a limb and say this is
the "right answer"?
The Matlab function we built passes identical projection parameters into
the proj library as I pass to cs2cs or proj or define in GRASS GIS. I
looked closer, and compiling the mex file as
mex -l proj /home/fanslow/Work/Code/Matlab_tools/cs2cs_proj4.c
uses matlab's version of the PROJ.4 library, which is of uknown origin.
My other method uses the library that I compiled (PROJ 4.6). (FYI a mex
file is an interface between matlab and other programming languages).
I guess the main question here is why one version of proj gives
different values than another when passed identical projection
parameters? We have Matlab's version (comes with the mapping toolbox)
and then we have the one I compiled giving different results. Do you
know if there was a change in how proj handled moving from an ellipse to
sphere since version 4.4?
Gerald I. Evenden wrote:
> On Thursday 21 August 2008 7:50:13 pm Faron Anslow wrote:
>> This is my first post to the list, so I hope this hasn't been covered
>> extensively elsewhere (probably has).
>> A Colleague and I are working with an atmospheric reanalysis product
>> (NARR) that is on a fairly odd projection. That projection being
> The projection is not odd, maybe the usage.
>> lambert conformal conic with a spherical earth with radius of 6371200
>> m. To assist in projecting site data, DEMs and etc from lat/long WGS84
>> coords to our spherical projection my colleague has written a matlab
>> interface to the proj library. Our problem arises when we compare
>> reprojected coordinate values from cs2cs or GRASS with the matlab mex
>> file result. For instance, with cs2cs, running:
>> cs2cs +proj=latlong +datum=WGS84 +to +proj=lcc +lat_1=50 +lat_2=50
>> +lat_0=50 +lon_0=-107 +a=6371200.0000000000 +es=0.0 +f=0.0 +no_defs -r
> Simpler to use proj:
> proj +proj=lcc +R=6371200 +lat_1=50 +lon_0=-107
> -8.667 70.933
> 2859697.41 4597308.07
> where the -8.667 is longitude and 70.933 is latitude.
>> on the coordinates 70.933 -8.667 will yield:
>> 2859697.41 4597308.07 0.00
>> while our matlab mex file gives:
>> 2873633.37 4593659.17 -12148.43
> The problem here is what are the projection parameter being used by matlab?
> What is the "mex" file. If the matlab is projecting with an elliptical earth
> then the values will be different. But who know what is going on within
> Sorry to not be able to help with the matlab stuff other than to point out
> that you need to know what is going on within that system and how is it
> projecting the data.
>> I suspect the problem is that documented in the FAQ, which requires the
>> addition of +nadgrids=@null to the proj command. However, when I add
>> this to the cs2cs call, the results don't change. When I add it to the
>> mex call, the mex file crashes (not set up to handle the @null I
>> guess). Our question is which result is the correct one? We suspect
>> that a big change in elevation should be expected when switching from
>> the WGS84 ellipsoid to the sphere. cs2cs from proj 4.4 installed on
>> another machine gives results that agree with our mex file.
>> Even stranger is that when we compile the mex file with the line:
>> mex Work/Code/Matlab_tools/cs2cs_proj4.c /usr/lib/libproj.a
>> instead of:
>> mex -l proj /home/fanslow/Work/Code/Matlab_tools/cs2cs_proj4.c
>> the matlab result matches that of the cs2cs command given above.
>> If anyone has any answers, or even if you want to try to project these
>> test coords using your proj install, and send those along, your help
>> would be greatly appreciated.
>> Thanks a ton,
Post Doctoral Researcher
Department of Earth and Ocean Sciences
The University of British Columbia
6339 Stores Road
Vancouver, British Columbia
Canada, V6T 1Z4
604 822 3063
More information about the Proj