[Proj] Convertion Lat/Long WGS84 -> UTM-WGS84 problem?

Jose Gonçalves jagoncal at gmail.com
Thu Oct 23 04:16:54 EST 2014


Hello

Two problems with your procedure:
- PROJ expects coordinates in the order long/lat and not lat/long
- You must specify the UTM zone number

echo 3.96338 51.0242 | cs2cs.exe +proj=latlong +ellps=WGS84 +to +proj=utm
+ellps=WGS84 +datum=WGS84 +zone=31 +units=m
567564.16       5652957.63 0.00

Regards

José Gonçalves


2014-10-23 9:13 GMT+01:00 Charles Clercq <charles.clercq at gmail.com>:

> 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;
> }
>
> ***********************************************************************************************************
>
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20141023/abb8d091/attachment.htm 


More information about the Proj mailing list