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 command to read lat-lon data into a lat-lon location or to read UTM data into a UTM location. GRASS also provides an 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 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

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 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 command reported by grassll2u.

You now have the data in UTM projection.

Reports of any problems etc will be entertained.

Terry Duell
Maribyrnong, Victoria, Australia
24 Sep 98

Go back to GRASS GIS FAQ...