r.in.mat.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <h2>DESCRIPTION</h2>
  2. <em>r.in.mat</em> will import a GRASS raster map from a Version 4 MAT-File
  3. which was created with Matlab or Octave.
  4. Attributes such as map title and bounds will also be imported if they exist.
  5. <br>
  6. <br>
  7. Specifically, the following array variables will be read:<br>
  8. <ul>
  9. <li><b> map_data</b>
  10. <li><b> map_name</b>
  11. <li><b> map_title</b>
  12. <li><b> map_northern_edge</b>
  13. <li><b> map_southern_edge</b>
  14. <li><b> map_eastern_edge</b>
  15. <li><b> map_western_edge</b>
  16. </ul>
  17. Any other variables in the MAT-file will be simply skipped over.<br>
  18. <br>
  19. The '<b>map_name</b>' variable is optional, if it exists, and is valid, the
  20. new map will be thus named. If it doesn't exist or a name is specified with
  21. the <b>output=</b> option, the raster map's name will be set to
  22. "<tt>MatFile</tt>" or the name specified respectively.
  23. (maximum 64 characters; normal GRASS naming rules apply)
  24. <br>
  25. <br>
  26. The '<b>map_title</b>' variable is optional, the map's title is set if it
  27. exists.
  28. <br>
  29. <br>
  30. The '<b>map_northern_edge</b>' and like variables are mandatory unless the
  31. user is importing to a "XY" non-georeferenced location
  32. (e.g. imagery data). Latitude and longitude values should be in decimal form.
  33. <h2>NOTES</h2>
  34. <em>r.in.mat</em> imports a Version 4 MAT-File. These files can be
  35. successfully created with more modern versions of Matlab and Octave
  36. (see "EXAMPLES" below).<br><br>
  37. Everything should be Endian safe, so the file to be imported can be simply
  38. copied between different system architectures without binary translation
  39. (caveat: see "TODO" below).<br><br>
  40. As there is no IEEE value for <tt>NaN</tt> in integer arrays, GRASS's null
  41. value may be used to represent it within these maps. Usually Matlab will save
  42. any integer based matrix with <tt>NaN</tt> values as a double-precision
  43. floating point array, so this usually isn't an issue. To save space, once the
  44. map is loaded into GRASS you can convert it back to an integer map with the
  45. following command:
  46. <div class="code"><pre>
  47. r.mapcalc "int_map = int(MATFile_map)"
  48. </pre></div>
  49. <tt>NaN</tt> values in either floating point or double-precision floating point
  50. matrices should translate into null values as expected.<br><br>
  51. <em>r.in.mat</em> must load the entire map array into memory before writing,
  52. therefore it might have problems with <i>huge</i> arrays.
  53. (a 3000x4000 DCELL map uses about 100mb RAM)<br><br>
  54. GRASS defines its map bounds at the outer-edge of the bounding cells, not at
  55. the coordinates of their centroids. Thus, the following Matlab commands may
  56. be used to determine and check the map's resolution information will be correct:
  57. <div class="code"><pre>
  58. [rows cols] = size(map_data)
  59. x_range = map_eastern_edge - map_western_edge
  60. y_range = map_northern_edge - map_southern_edge
  61. ns_res = y_range/rows
  62. ew_res = x_range/cols
  63. </pre></div>
  64. <br>
  65. Remember Matlab arrays are referenced as <tt>(row,column)</tt>,
  66. i.e. <tt>(y,x)</tt>.
  67. <br><br>
  68. In addition, <em>r.in.mat</em> and <em>r.out.mat</em> make for a nice
  69. binary container format for transferring georeferenced maps around,
  70. even if you don't use Matlab or Octave.
  71. <h2>EXAMPLES</h2>
  72. In Matlab, save with:
  73. <div class="code"><pre>
  74. save filename.mat map_* -v4
  75. </pre></div>
  76. In Octave, save with:
  77. <div class="code"><pre>
  78. save -mat4-binary filename.mat map_*
  79. </pre></div>
  80. <br>
  81. <h2>TODO</h2>
  82. Robust support for mixed-Endian importation.
  83. <i>(This is a work in progress, please help by reporting any failures to the
  84. <a href="http://trac.osgeo.org/grass/">
  85. GRASS bug tracking system</a></i>; you will need to login with an OSGeo Userid)
  86. <br>
  87. Add support for importing map history, category information, color map, etc.
  88. if they exist.
  89. <br>
  90. Option to import a version 5 MAT-File, with map and support information
  91. stored in a single structured array.
  92. <h2>KNOWN ISSUES</h2>
  93. If you encounter any problems, please contact the GRASS Development Team.
  94. <h2>SEE ALSO</h2>
  95. <em>
  96. <a href="r.out.mat.html">r.out.mat</a>,
  97. <a href="r.in.ascii.html">r.in.ascii</a>,
  98. <a href="r.in.bin.html">r.in.bin</a>,
  99. <a href="r.mapcalc.html">r.mapcalc</a>,
  100. <a href="r.null.html">r.null</a>.
  101. </em>
  102. <p><em>
  103. The <a href="http://www.octave.org">Octave</a> project
  104. </em>
  105. <h2>AUTHOR</h2>
  106. Hamish Bowman<br> <i>
  107. Department of Marine Science<br>
  108. University of Otago<br>
  109. New Zealand</i><br>
  110. <br>
  111. <p><i>Last changed: $Date$</i>