r.out.mat(1grass)
π r.out.mat β the GRASS User's Manual glow-up π
ok so bestie, welcome to r.out.mat(1grass), the little GRASS module that takes your raster and yeets it into a binary MAT-File. it's giving "export era". let's get into it π¦
β¨ NAME β¨
r.out.mat β Exports a GRASS raster to a binary MAT-File. that's it, that's the whole job, and she does it flawlessly π
π·οΈ KEYWORDS π·οΈ
raster, export, output
π SYNOPSIS π
r.out.mat
r.out.mat --help
r.out.mat input=name output=name [--overwrite] [--help] [--verbose]
[--quiet] [--ui]
π© Flags:
--overwriteβ Allow output files to overwrite existing files. she WILL replace your old file, no hesitation.--helpβ Print usage summary. for when you're lost (real).--verboseβ Verbose module output. she talks a lot, we love that for her.--quietβ Quiet module output. she says nothing, mysterious queen.--uiβ Force launching GUI dialog. buttons instead of typing, valid honestly.
π Parameters:
input=name[required] β Name of input raster map. required, bestie, don't forget her.output=name[required] β Name for output binary MAT file. also required. both of them. no skipping π€
πΈ DESCRIPTION πΈ
so r.out.mat will export a GRASS raster map to a MAT-File which can be loaded into Matlab or Octave for plotting or further analysis. plotting era!! π
and the way it's not just the raw data β Attributes such as map title and bounds will also be exported into additional array variables. extra, generous, iconic.
Specifically, the following array variables are created:
map_datamap_namemap_title(if it exists)map_northern_edgemap_southern_edgemap_eastern_edgemap_western_edge
In addition, r.out.mat makes for a nice binary container format for transferring georeferenced maps around, even if you don't use Matlab or Octave. so even if you're not a Matlab girlie, she's still serving as your transport layer. multi-purpose queen π
π NOTES π
r.out.mat exports a Version 4 MAT-File. These files should successfully load into more modern versions of Matlab and Octave without any problems. backwards compatible, she's polite like that π«Ά
Everything should be Endian safe, so the resultant file can be simply copied between different system architectures without binary translation. no translation arc needed, just copy and go β¨
As there is no IEEE value for NaN for integer maps, GRASS's null value is used to represent it within these maps. so you'll have to do something like this to clean them once the map is loaded into Matlab:
map_data(find(map_data < -1e9)) = NaN;
Null values in maps containing either floating point or double-precision floating point data should translate into NaN values as expected. so float girlies are fine, it's the integer maps that need that little cleanup moment.
ok this next part is the real talk: r.out.mat must load the entire map into memory before writing, therefore it might have problems with huge maps. like, (a 3000x4000 DCELL map uses about 100mb RAM). she's holding the whole thing in her head at once. respect, but also, mind your RAM π
GRASS defines its map bounds at the outer-edge of the bounding cells, not at the coordinates of their centroids. Thus, the following Matlab commands may be used to determine the map's resolution information:
[rows cols] = size(map_data)
x_range = map_eastern_edge - map_western_edge
y_range = map_northern_edge - map_southern_edge
ns_res = y_range/rows
ew_res = x_range/cols
math but make it cute, periodt.
π EXAMPLE π
In Matlab, plot with either:
imagesc(map_data), axis equal, axis tight, colorbar
or
contourf(map_data, 24), axis ij, axis equal, axis tight, colorbar
two options, both slay, pick your vibe π¨
π§ TODO π§
the wishlist, the vision board, the "one day" board:
- Add support for exporting map history, category information, color map, etc.
- Option to export as a version 5 MAT-File, with map and support information stored in a single structured array.
manifesting it fr fr π§
π SEE ALSO π
r.in.matr.out.ascii,r.out.binr.null- The Octave project
π AUTHOR π
Hamish Bowman Department of Marine Science University of Otago New Zealand
π SOURCE CODE π
Available at: r.out.mat source code (history)
Latest change: Thursday May 08 20:58:05 2025 in commit: 4144ba81fa125e1549fc52e1cf5feb4fa004be8b
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
and that's the whole manual, bestie π
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
mwah, this was GRASS 8.5.0 presenting r.out.mat(1grass) β go export something gorgeous, you've got this ππ π¦
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms