[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Search Page]

UTM meters <--> lon-lat




Hi, GMT-folks

I raised the question of conversions between UTM meters and lon-lat
a week or so ago, got a helpful reply, and had a number of requests to
pass on any solutions which might come my way.  Here goes...

1) converting UTM meters <--> lon-lat
Andy Goodliffe pointed out a straightforward way of doing this with
mapproject.  Here is an example of some lines to convert a single lat-lon
pair to the equivalent UTM meter position (eastings and northings):

set REF_ELLIPSOID = WGS-84
set UTM_ZONE = 25
set LAT =  37.331 ; set LON = -32.266
gmtset D_FORMAT %12.5f
gmtset ELLIPSOID $REF_ELLIPSOID
echo $LON $LAT $LON $LAT | \
   mapproject -R0/1/0/1 -F -C -Ju$UTM_ZONE/1:1 


It's probably a good idea to explicitely specify the reference ellipsoid
(GMT defaults to WGS-84 but the UTM projection as defined, is based on
Clarke-1866).  You also need to specify the UTM zone.  I change the
D_FORMAT gmtdefault so it doesn't truncate some useful digits.  I checked
out a couple of these conversions using examples from John Snyder's book
(USGS, 1987?), and my results (UTM meters) agreed to better than 1 ppm
with his.  Thus, I think this conversion can be viewed as exact.

The way to go from UTM meters to Lon-lat's is to use exactly the same
command but add the -I (inverse) option.

I'm pretty sure that when using mapproject with -C, the -R region which
is specified really doesn't make any difference; hence, I just used a
generic region.

The extension of these conversions to many lon-lat or XY pairs is
straightforward.


2)  Superimposing Lon-lat ticks/lines on UTM XY ticks/lines.

My goal is to plot grids with both lon-lat and UTM XY ticks/lines/annotations
superimposed.

I am able to do this fairly simply when my grid is in UTM meters.  Basically,
just plot the grid and whatever UTM meter basemap on top of it.  Then,
figure out the lon-lat values of the lower-left and upper-right positions of the
UTM meter basemap.  Then, plot a new basemap on top of this, using 
the -JU$UTM_ZONE/$XSIZE specification (where $XSIZE is the width of the
UTM meter basemap) and the -R(lower-left/upper-right)r lon-lat specification.
This -R...r makes the outline of the basemap from this call rectangular;
individual lon or lat grid lines are not exactly vertical or horizontal.

Actually, the 









UTM meters <--> lon-lat









[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Search Page]

UTM meters <--> lon-lat




Hi, GMT-folks

I raised the question of conversions between UTM meters and lon-lat
a week or so ago, got a helpful reply, and had a number of requests to
pass on any solutions which might come my way.  Here goes...

1) converting UTM meters <--> lon-lat
Andy Goodliffe pointed out a straightforward way of doing this with
mapproject.  Here is an example of some lines to convert a single lat-lon
pair to the equivalent UTM meter position (eastings and northings):

set REF_ELLIPSOID = WGS-84
set UTM_ZONE = 25
set LAT =  37.331 ; set LON = -32.266
gmtset D_FORMAT %12.5f
gmtset ELLIPSOID $REF_ELLIPSOID
echo $LON $LAT $LON $LAT | \
   mapproject -R0/1/0/1 -F -C -Ju$UTM_ZONE/1:1 


It's probably a good idea to explicitely specify the reference ellipsoid
(GMT defaults to WGS-84 but the UTM projection as defined, is based on
Clarke-1866).  You also need to specify the UTM zone.  I change the
D_FORMAT gmtdefault