Transfer of lat-lon raster to UTM

Terry Duell duell at atea.mat.army.defence.gov.au
Wed Sep 23 20:55:32 EDT 1998


Ladies and Gentlemen,
I now have a working method of transferring lat-lon raster (cell) data
to a UTM location/mapset, which may be of help/assistance to some of
you.
I have written little ditty which explains how it all works, and this is
attached.
If anyone would like the software please contact me. I would be happy to
have it available to download from the GRASS web site, if there is
sufficient interest.

Cheers,
-- 
Terry Duell, Senior Mobility Engineer
Army Technology & Engineering Agency                   
Maribyrnong, Victoria, Australia
ph:61-3-93195837 fax:61-3-93195830
-------------- next part --------------
Transfer of GRASS raster data (cell) from a lat-lon location/mapset to
a UTM location/mapset.

GRASS provides an r.out.ascii command which writes out an ascii file
from a lat-lon or a UTM location, and also provides an r.in.ascii
command to read lat-lon data into a lat-lon location or to read UTM
data into a UTM location. GRASS also provides an r.in.ll command which
reads a binary lat-lon raster into a UTM location providing projection
conversion in the process. What GRASS doesn't provide is an easy means
of exporting a rectangular segment of lat-lon data to a UTM
location. What is really needed is the equivalent of the r.out.ascii
and the r.in.ascii with projection conversion on the fly.

In an attempt to alleviate this situation I have built a stand alone
tool (called 'grassll2u') which will read a lat-lon raster file saved
out using r.out.ascii, and process it into a file which can be
imported into a UTM location using r.in.ll.

The tool reports the command line to use with m.ll2u to provide the
UTM coordinates one should use for the region in the UTM location
prior to importing the data (using a larger region than the data is
wasteful as the resulting cell file has to be padded out with zeros,
which can take time), and reports the command line to use with r.in.ll
to carry out the importation process.

The tool has been written in f77 and has been tested on IRIX 6.2. It
does have some Australian peculiarities 'hard wired' in, such as
expecting to be in the south eastern hemisphere, and the wgs84
spheroid, but these issues are not significant changes if required.

The process is as follows...
(note that this is how I am using it on an IRIX system, and I can't be
absolutely certain that it would be same on other systems)

Compile grassll2u.f and place the resulting exectable (grassll2u) in
the /usr/local/bin directory, and ensure that all have this in their
path.

Start GRASS in your lat-lon location/mapset.

Set your region to the rectangular area of data that you want to
export to UTM.

Run r.out.ascii fred.cell > fred.dat. where fred.cell is the ll cell
file in question and fred.dat is the resulting ascii cut out, now
written to your current directory.

Run grassll2u and answer the questions, providing 'fred.dat' as the
input.

Run the m.ll2u command (command line displayed by grassll2u) and then
examine the resulting file to see the UTM coordinates of the exported
data. This will also provide the UTM zone, hence tell you which
location you can (legally) import into.

Exit GRASS, then restart GRASS in the UTM location/mapset.

Run g.region and set the current region to (or near) the extents
reported in the file produced by m.ll2u.

Run the r.in.ll command reported by grassll2u.

You now have the data in UTM projection.

Reports of any problems etc will be entertained.

Terry Duell
ATEA 
24 Sep 98  


More information about the grass-user mailing list