how to convert UTM to LatLon..??

1 message Options
Embed this post
Permalink
rakeshthp

how to convert UTM to LatLon..??

Reply Threaded More More options
Print post
Permalink
hi...

i found this code here..

Code:

double x[] = {72.56, 74.37, 76.66, 77.00};
double y[] = {8.83, 8.97, 10.23, 10.9};

projPJ pj_utm, pj_latlong;

if( !(pj_utm = pj_init_plus("+proj=utm +ellps=WGS84 +zone=43")))
   exit(1);

if( !(pj_latlong = pj_init_plus("+proj=latlong +ellps=WGS84")))
   exit(1);

for( int i = 0; i < 4; i++ )
{
   x[i] *= DEG_TO_RAD;
   y[i] *= DEG_TO_RAD;
}

int p = pj_transform(pj_latlong, pj_utm, 4, 1, x, y, NULL);

for( int i = 0; i < 4; i++ )
   printf("%0.2f\t%0.2f\n",x[i],y[i]);



This piece of code will convert lat lon to UTM... (as per my requirement)

Now what do i do to get the reverse thing done..?? should i just replace

   int p = pj_transform(pj_latlong, pj_utm, 4, 1, x, y, NULL);

by

   int p = pj_transform( pj_utm, pj_latlong, 4, 1, x, y, NULL);

or anything else need to be done..?

Thanks in advance..