[Proj] Convertion Lat/Long WGS84 -> UTM-WGS84 problem?
Charles Clercq
charles.clercq at gmail.com
Thu Oct 23 01:13:45 PDT 2014
Dear all,
I have written a simple basic code inspired from the doc to convert data in
lat/long WGS84 in meters (UTM/WGS84)
My problem is that when I tested it with lat: 51.0242 / long: 3.96338 and
obtained x: 7627600.282316 / y: 742130.588781 which I compared with online
converter which gave me : 5652958 / 567564
I would like to understand the error. I that because proj can't convert
from WGS84 lat/long to UTM WGS84 ?
I tested with command line:
echo 51.0242 3.96338 | cs2cs.exe +proj=latlong +ellps=WGS84 +to +proj=utm
+ellps=WGS84 +datum=WGS84 +units=m
and obtained the exact same result.
Any advice?
Thanks
Clercq
The code
***********************************************************************************************************
#include <iostream>
#include <proj_api.h>
int _tmain(int argc, _TCHAR* argv[])
{
projPJ pj_merc, pj_latlong;
double x, y;
if (!(pj_merc = pj_init_plus("+proj=utm +ellps=WGS84 +datum=WGS84
+units=m")) )
exit(1);
if (!(pj_latlong = pj_init_plus("+proj=latlong +ellps=WGS84")) )
exit(1);
std::cout << "Lat: ";
double latitude;
std::cin >> latitude;
std::cout << std::endl;
std::cout << "Long: ";
double longitude;
std::cin >> longitude;
x = latitude*DEG_TO_RAD;
y = longitude*DEG_TO_RAD;
int p = pj_transform(pj_latlong, pj_merc, 1, 1, &x, &y, NULL );
//std::cout << "The coordinate in meters are: " << x << "/" << y <<
std::endl;
printf("Lat/Long: %f/%f - in meters ->: %f/%f\n", latitude, longitude, x,
y);
return 0;
}
***********************************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20141023/fd46008a/attachment.html>
More information about the Proj
mailing list