[Proj] Proj4js, cs2cs and pj_transform
Cyril Bondue
c.bondue at hotmail.com
Wed Dec 7 12:58:35 PST 2011
Hello fellow coders!
I'm writing to ask for your help. I need to convert data from NTF (Paris) / Lambert Centre France (epsg 27562) to WGS84 (epsg 4326). To test Proj4 I used the web interface Proj4js, and i could do the conversion without much troubles. Here are the two projPj I used, and working :
- source : +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs
- dest : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
Good! But I need to do the conversion in a C++ program, so I downloaded the source, downloaded the NAD for France (who were already in the archive BTW), compiled with MinGW (i'm doing a Windows software), compilation runs without problems, great!
Now, troubles ^^
Here is my code :
projPJ source = pj_init_plus("+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs");
projPJ dest = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
double x = 535003.285368d;
double y = 200358.358412d;
pj_transform(source, dest, 1, 1, &x, &y, NULL);
pj_transform returns 0 (OK), but x and y are wrong. I have x=0.0259181 and y=0.816814 while the correct results are 1.485 and 46.8 (rounded up), results that Proj4Js confirms.
I also tried the same transformation on cs2cs :
cs2cs.exe +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356 515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs +to +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
535003.285368 200358.358412
Results are different and also wrong (or i can't read them right) x=1d29'6"E, y=46d48'N 44.005
I have taken care of settings PROJ_LIB with the nad folder. So i must do something wrong, i've tried many things but i don't understand what happens, so here I am, asking you for some assistance. Can you see what's going on?
Thank you in advance!
Cyril
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20111207/d9e830b8/attachment.html>
More information about the Proj
mailing list