<div dir="ltr"><div><div><div><div>Hello<br><br></div>Two problems with your procedure:<br></div>- PROJ expects coordinates in the order long/lat and not lat/long<br></div>- You must specify the UTM zone number<br></div><br><div>echo 3.96338 51.0242 | cs2cs.exe +proj=latlong +ellps=WGS84 +to +proj=utm +ellps=WGS84 +datum=WGS84 +zone=31 +units=m<br>567564.16 5652957.63 0.00<br><div><br></div><div>Regards<br><br></div><div>José Gonçalves<br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-23 9:13 GMT+01:00 Charles Clercq <span dir="ltr"><<a href="mailto:charles.clercq@gmail.com" target="_blank">charles.clercq@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div>I have written a simple basic code inspired from the doc to convert data in lat/long WGS84 in meters (UTM/WGS84)</div><div>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</div><div><br></div><div>I would like to understand the error. I that because proj can't convert from WGS84 lat/long to UTM WGS84 ?</div><div><br></div><div>I tested with command line:</div><div><div>echo 51.0242 3.96338 | cs2cs.exe +proj=latlong +ellps=WGS84 +to +proj=utm +ellps=WGS84 +datum=WGS84 +units=m</div></div><div>and obtained the exact same result.</div><div><br></div><div>Any advice?</div><div><br></div><div>Thanks</div><div><br></div><div>Clercq</div><div><br></div><div>The code</div><div>***********************************************************************************************************</div><div><div>#include <iostream></div><div><br></div><div>#include <proj_api.h></div><div><br></div><div>int _tmain(int argc, _TCHAR* argv[])</div><div>{</div><div><span style="white-space:pre-wrap">        </span>projPJ pj_merc, pj_latlong;</div><div> double x, y;</div><div><br></div><div> if (!(pj_merc = pj_init_plus("+proj=utm +ellps=WGS84 +datum=WGS84 +units=m")) )</div><div> exit(1);</div><div> if (!(pj_latlong = pj_init_plus("+proj=latlong +ellps=WGS84")) )</div><div> exit(1);</div><div><span style="white-space:pre-wrap">        </span>std::cout << "Lat: ";</div><div><span style="white-space:pre-wrap">        </span>double latitude;</div><div><span style="white-space:pre-wrap">        </span>std::cin >> latitude;</div><div><span style="white-space:pre-wrap">        </span>std::cout << std::endl;</div><div><span style="white-space:pre-wrap">        </span>std::cout << "Long: ";</div><div><span style="white-space:pre-wrap">        </span>double longitude;</div><div><span style="white-space:pre-wrap">        </span>std::cin >> longitude;</div><div><br></div><div> x = latitude*DEG_TO_RAD;</div><div><span style="white-space:pre-wrap">        </span>y = longitude*DEG_TO_RAD;</div><div><br></div><div> int p = pj_transform(pj_latlong, pj_merc, 1, 1, &x, &y, NULL );</div><div><br></div><div><span style="white-space:pre-wrap">        </span>//std::cout << "The coordinate in meters are: " << x << "/" << y << std::endl;</div><div><span style="white-space:pre-wrap">        </span>printf("Lat/Long: %f/%f - in meters ->: %f/%f\n", latitude, longitude, x, y);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>return 0;</div><div>}</div></div><div>***********************************************************************************************************<br></div></div>
<br>_______________________________________________<br>
Proj mailing list<br>
<a href="mailto:Proj@lists.maptools.org">Proj@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/proj" target="_blank">http://lists.maptools.org/mailman/listinfo/proj</a><br></blockquote></div><br></div>