1r.in.mat(1) GRASS GIS User's Manual r.in.mat(1)
2
3
4
6 r.in.mat - Imports a binary MAT-File(v4) to a GRASS raster.
7
9 raster, import
10
12 r.in.mat
13 r.in.mat --help
14 r.in.mat input=name [output=name] [--overwrite] [--help] [--ver‐
15 bose] [--quiet] [--ui]
16
17 Flags:
18 --overwrite
19 Allow output files to overwrite existing files
20
21 --help
22 Print usage summary
23
24 --verbose
25 Verbose module output
26
27 --quiet
28 Quiet module output
29
30 --ui
31 Force launching GUI dialog
32
33 Parameters:
34 input=name [required]
35 Name of input MAT-File(v4)
36
37 output=name
38 Name for output raster map (override)
39
41 r.in.mat will import a GRASS raster map from a Version 4 MAT-File which
42 was created with Matlab or Octave. Attributes such as map title and
43 bounds will also be imported if they exist.
44 Specifically, the following array variables will be read:
45
46 •
47 map_data
48
49 •
50 map_name
51
52 •
53 map_title
54
55 •
56 map_northern_edge
57
58 •
59 map_southern_edge
60
61 •
62 map_eastern_edge
63
64 •
65 map_western_edge
66 Any other variables in the MAT-file will be simply skipped over.
67 The ’map_name’ variable is optional, if it exists, and is valid, the
68 new map will be thus named. If it doesn’t exist or a name is specified
69 with the output= option, the raster map’s name will be set to "MatFile"
70 or the name specified respectively. (maximum 64 characters; normal
71 GRASS naming rules apply)
72 The ’map_title’ variable is optional, the map’s title is set if it ex‐
73 ists.
74 The ’map_northern_edge’ and like variables are mandatory unless the
75 user is importing to a "XY" non-georeferenced location (e.g. imagery
76 data). Latitude and longitude values should be in decimal form.
77
79 r.in.mat imports a Version 4 MAT-File. These files can be successfully
80 created with more modern versions of Matlab and Octave (see "EXAMPLES"
81 below).
82 Everything should be Endian safe, so the file to be imported can be
83 simply copied between different system architectures without binary
84 translation (caveat: see "TODO" below).
85 As there is no IEEE value for NaN in integer arrays, GRASS’s null value
86 may be used to represent it within these maps. Usually Matlab will save
87 any integer based matrix with NaN values as a double-precision floating
88 point array, so this usually isn’t an issue. To save space, once the
89 map is loaded into GRASS you can convert it back to an integer map with
90 the following command:
91 r.mapcalc "int_map = int(MATFile_map)"
92 NaN values in either floating point or double-precision floating point
93 matrices should translate into null values as expected.
94 r.in.mat must load the entire map array into memory before writing,
95 therefore it might have problems with huge arrays. (a 3000x4000 DCELL
96 map uses about 100mb RAM)
97 GRASS defines its map bounds at the outer-edge of the bounding cells,
98 not at the coordinates of their centroids. Thus, the following Matlab
99 commands may be used to determine and check the map’s resolution infor‐
100 mation will be correct:
101 [rows cols] = size(map_data)
102 x_range = map_eastern_edge - map_western_edge
103 y_range = map_northern_edge - map_southern_edge
104 ns_res = y_range/rows
105 ew_res = x_range/cols
106 Remember Matlab arrays are referenced as (row,column), i.e. (y,x).
107 In addition, r.in.mat and r.out.mat make for a nice binary container
108 format for transferring georeferenced maps around, even if you don’t
109 use Matlab or Octave.
110
112 In Matlab, save with:
113 save filename.mat map_* -v4
114 In Octave, save with:
115 save -mat4-binary filename.mat map_*
116
118 Robust support for mixed-Endian importation. (This is a work in
119 progress, please help by reporting any failures to the GRASS bug track‐
120 ing system;
121 Add support for importing map history, category information, color map,
122 etc. if they exist.
123 Option to import a version 5 MAT-File, with map and support information
124 stored in a single structured array.
125
127 If you encounter any problems, please contact the GRASS Development
128 Team.
129
131 r.out.mat, r.in.ascii, r.in.bin, r.mapcalc, r.null.
132
133 The Octave project
134
136 Hamish Bowman
137 Department of Marine Science
138 University of Otago
139 New Zealand
140
142 Available at: r.in.mat source code (history)
143
144 Accessed: Mon Jun 20 16:46:06 2022
145
146 Main index | Raster index | Topics index | Keywords index | Graphical
147 index | Full index
148
149 © 2003-2022 GRASS Development Team, GRASS GIS 8.2.0 Reference Manual
150
151
152
153GRASS 8.2.0 r.in.mat(1)