new module: r.out.mat (was: [GRASS5] color in GRASS)

Hamish hamish_nospam at
Tue Mar 23 06:12:55 EST 2004

> As part of my menu updating, I've added some ways to more easily get 
> GRASS output into other programs.

FYI, I've also just finished a preliminary r.out.mat for exporting maps
to Matlab for plotting/analysis/whatever. It's in 5.3's CVS now..
Specifically I'd be interested in how it works for anyone not on linux &
i386 (64bit / big endian anyone?). If Matlab is out of your price range,
"Octave" which is a Free GPL clone can load these files too, but still
has a couple rough edges. I expect r.out.mat will be upgraded and will arrive at some point; it's a trickier beast to get right
for all cases.

some notes:

* MAT-File v4 for now, probably v5 later (with variables nicely placed
  in a nested structure)
* Everything should be endian safe, currently untested
* In Matlab, plot with either 'image(map_data)' or something like:
    contourf(map_data), axis ij, axis equal, axis tight, colorbar
* As there is no IEEE value for NaN (AFAIK) for integer maps, GRASS's
  null value is used to represent it for these maps. You'll have to do
  something like this to clean them once they are in Matlab:
    map_data(find(map_data < -1e9)) = NaN;
  Floats and Doubles should work as expected.
* It has to load the entire map into memory before writing, therefore
  it might have problems with *huge* maps. Generally cells*sizeof(type).
  (a 3000x4000 DCELL map uses ~100mb RAM)
* It works.

I hope it is of some use to someone..


More information about the grass-dev mailing list