rasterintro.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Raster data processing in GRASS GIS</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta name="Author" content="Markus Neteler/GRASS Development Team">
  7. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  8. </head>
  9. <body bgcolor="white">
  10. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  11. <!-- meta page description: Raster data processing -->
  12. <h2>Raster data processing in GRASS GIS</h2>
  13. <h3>Raster maps in general</h3>
  14. A "raster map" is a data layer consisting of a gridded array of cells.
  15. It has a certain number of rows and columns, with a data point (or null
  16. value indicator) in each cell. These may exist as a 2D grid or as a 3D
  17. cube made up of many smaller cubes, i.e. a stack of 2D grids.
  18. <p>
  19. The geographic boundaries of the raster map are described by the north,
  20. south, east, and west fields. These values describe the lines which bound
  21. the map at its edges. These lines do NOT pass through the center of the
  22. grid cells at the edge of the map, but along the edge of the map itself.
  23. i.e. the geographic extent of the map is described by the outer bounds of
  24. all cells within the map.
  25. <P>
  26. As a general rule in GRASS:
  27. <ol>
  28. <li> Raster output maps have their bounds and resolution equal to those
  29. of the current computational region.
  30. <li> Raster input maps are automatically cropped/padded and rescaled
  31. (using nearest-neighbour resampling) to match the current region.
  32. <li> Raster input maps are automatically masked if a raster map named
  33. MASK exists. The MASK is only applied when <i>reading</i> maps
  34. from the disk.
  35. </ol>
  36. There are a few exceptions to this:
  37. <tt>r.in.*</tt> programs read the data cell-for-cell, with no resampling. When
  38. reading non-georeferenced data, the imported map will usually have its
  39. lower-left corner at (0,0) in the location's coordinate system; the user
  40. needs to use <a href="r.region.html">r.region</a> to "place" the imported map.
  41. <P>
  42. Some programs which need to perform specific types of resampling (e.g.
  43. <a href="r.resamp.rst.html">r.resamp.rst</a>) read the input maps at
  44. their original resolution then do the resampling themselves.
  45. <P>
  46. <a href="r.proj.html">r.proj</a> has to deal with two regions (source
  47. and destination) simultaneously; both will have an impact upon the
  48. final result.
  49. <h3>Raster import and export</h3>
  50. The module <a href="r.in.gdal.html">r.in.gdal</a> offers a common
  51. interface for many different raster formats. Additionally, it also
  52. offers options such as on-the-fly location creation or extension of
  53. the default region to match the extent of the imported raster map.
  54. For special cases, other import modules are available. The full map
  55. is always imported.
  56. <P>
  57. For importing scanned maps, the user will need to create a
  58. x,y-location, scan the map in the desired resolution and save it into
  59. an appropriate raster format (e.g. tiff, jpeg, png, pbm) and then use
  60. <a href="r.in.gdal.html">r.in.gdal</a> to import it. Based on
  61. reference points the scanned map can be recified to obtain geocoded
  62. data.
  63. <P>
  64. Raster maps are exported with <a href="r.out.gdal.html">r.out.gdal</a>
  65. into common formats. Also <a href="r.out.bin.html">r.out.bin</a>,
  66. <a href="r.out.vtk.html">r.out.vtk</a>, <a href="r.out.ascii.html">r.out.ascii</a>
  67. and other export modules are available. They export the data according
  68. to the current region settings. If those differ from the original map,
  69. the map is resampled on the fly (nearest neighbor algorithm). In other
  70. words, the output will have as many rows and columns as the current region.
  71. To export maps with various grid spacings (e.g, 500x500 or 200x500), you
  72. can just change the region resolution with <a href="g.region.html">g.region</a>
  73. and then export the map. The resampling is done with nearest neighbor
  74. algorithm in this case. If you want some other form of resampling,
  75. first change the region, then explicitly resample the map with e.g.
  76. <a href="r.resamp.interp.html">r.resamp.interp</a> or
  77. <a href="r.resamp.stats.html">r.resamp.stats</a>, then export the
  78. resampled map.
  79. <h3>Metadata</h3>
  80. The <a href="r.info.html">r.info</a> module displays general information
  81. about a map such as region extent, data range, data type, creation history,
  82. and other metadata.
  83. Metadata such as map title, units, vertical datum etc. can be updated
  84. with <a href="r.support.html">r.support</a>. Timestamps are managed
  85. with <a href="r.timestamp.html">r.timestamp</a>. Region extent and
  86. resolution are mangaged with <a href="r.region.html">r.region</a>.
  87. <h3>Raster map operations</h3>
  88. <h4>Resampling methods and interpolation methods</h4>
  89. GRASS raster map processing is always performed in the current region
  90. settings (see <a href="g.region.html">g.region</a>), i.e. the current
  91. region extent and current raster resolution is used. If the resolution
  92. differs from that of the input raster map(s), on-the-fly resampling is
  93. performed (nearest neighbor resampling). If this is not desired, the
  94. input map(s) has/have to be resampled beforehand with one of the dedicated
  95. modules.
  96. <p>
  97. The built-in nearest-neighbour resampling of raster data calculates
  98. the centre of each region cell, and takes the value of the raster cell
  99. in which that point falls.
  100. <p>
  101. If the point falls exactly upon a grid line, the exact result will be
  102. determined by the direction of any rounding error. One consequence of
  103. this is that downsampling by a factor which is an even integer will
  104. always sample exactly on the boundary between cells, meaning that the
  105. result is ill-defined.
  106. <p>
  107. The following modules are available for reinterpolation of "filled"
  108. raster maps (continuous data) to a different resolution:
  109. <ul>
  110. <li><a href="r.resample.html">r.resample</a> uses the built-in resampling,
  111. so it should produce identical results as the on-the-fly resampling done
  112. via the raster import modules.</li>
  113. <li><a href="r.resamp.interp.html">r.resamp.interp</a> Resampling with
  114. nearest neighbor, bilinear, and bicubic method: <b>method=nearest</b> uses the
  115. same algorithm as <a href="r.resample.html">r.resample</a>, but not the same
  116. code, so it may not produce identical results in cases which are decided
  117. by the rounding of floating-point numbers.
  118. <br>
  119. For <a href="r.resamp.interp.html">r.resamp.interp</a> <b>method=bilinear</b>
  120. and <b>method=bicubic</b>, the raster values are treated as samples at each
  121. raster cell's centre, defining a piecewise-continuous surface. The resulting
  122. raster values are obtained by sampling the surface at each region cell's centre.
  123. As the algorithm only interpolates, and doesn't extrapolate, a margin of 0.5
  124. (for bilinear) or 1.5 (for bicubic) cells is lost from the extent of the original
  125. raster. Any samples taken within this margin will be null.</li>
  126. <li><a href="r.resamp.rst.html">r.resamp.rst</a> Regularized Spline with Tension
  127. (RST) interpolation 2D: Behaves similarly, i.e. it computes a surface assuming
  128. that the values are samples at each raster cell's centre, and samples the surface
  129. at each region cell's centre.
  130. <p>
  131. <li>For <a href="r.resamp.stats.html">r.resamp.stats</a> without <b>-w</b>, the value of
  132. each region cell is the chosen aggregate of the values from all of the raster
  133. cells whose centres fall within the bounds of the region cell.
  134. <br>
  135. With <b>-w</b>, the samples are weighted according to the proportion of the
  136. raster cell which falls within the bounds of the region cell, so the
  137. result is normally unaffected by rounding error (a miniscule difference
  138. in the position of the boundary results in the addition or subtraction of
  139. a sample weighted by a miniscule factor; also, The min and max aggregates
  140. can't use weights, so <b>-w</b> has no effect for those).</li>
  141. <li> <a href="r.fillnulls.html">r.fillnulls</a> for Regularized Spline with Tension (RST)
  142. interpolation 2D for hole filling (e.g., SRTM DEM)</li>
  143. </ul>
  144. <p>
  145. Furthermore, there are modules available for reinterpolation of "sparse"
  146. (scattered points or lines) maps:
  147. <ul>
  148. <li> Inverse distance weighted average (IDW) interpolation
  149. (<a href="r.surf.idw.html">r.surf.idw</a> and <a href="r.surf.idw2.html">r.surf.idw2</a>)</li>
  150. <li> Interpolating from contour lines (<a href="r.contour.html">r.contour</a>)</li>
  151. </ul>
  152. For Lidar and similar data, <a href="r.in.xyz.html">r.in.xyz</a> supports loading
  153. and binning of ungridded x,y,z ASCII data into a new raster map. The user may choose from
  154. a variety of statistical methods in creating the new raster.
  155. <p>
  156. Otherwise, for interpolation of scattered data, use the <EM>v.surf.*</EM> set of
  157. modules.
  158. <h4>Raster MASKs</h4>
  159. If a raster map named "MASK" exists, most GRASS raster modules will operate
  160. only on data falling inside the masked area, and treat any data falling
  161. outside of the mask as if its value were NULL. The mask is only applied
  162. when <em>reading</em> an existing GRASS raster map, for example when used
  163. in a module as an input map.
  164. <p>
  165. The mask is read as an integer map. If MASK is actually a
  166. floating-point map, the values will be converted to integers using the
  167. map's quantisation rules (this defaults to round-to-nearest, but can
  168. be changed with r.quant).
  169. <P>
  170. (see <a href="r.mask.html">r.mask</a>)
  171. <h3>Raster map statistics</h3>
  172. A couple of commands are available to calculate local statistics
  173. (<a href="r.neighbors.html">r.neighbors</a>), and global statistics
  174. (<a href="r.statistics.html">r.statistics</a>, <a href="r.surf.area.html">r.surf.area</a>,
  175. <a href="r.sum.html">r.sum</a>). Profiles and transects can be generated
  176. (<a href="d.profile.html">d.profile</a>, <a href="r.profile.html">r.profile</a>,
  177. <a href="r.transect.html">r.transect</a>) as well as histograms
  178. (<a href="d.histogram.html">d.histogram</a>) and polar diagrams
  179. (<a href="d.polar.html">d.polar</a>).
  180. Univariate statistics (<a href="r.univar.html">r.univar</a>) and
  181. reports are also available (<a href="r.report.html">r.report</a>,<a
  182. href="r.stats.html">r.stats</a>, <a href="r.volume.html">r.volume</a>).
  183. <h3>Raster map algebra and aggregation</h3>
  184. The <a href="r.mapcalc.html">r.mapcalc</a> command provides raster map
  185. algebra methods.
  186. The <a href="r.resamp.stats.html">r.resamp.stats</a> command resamples raster
  187. map layers using various aggregation methods, the <a href="r.average.html">r.average</a>
  188. command aggregates one map based on a second map.
  189. <a href="r.resamp.interp.html">r.resamp.interp</a> resamples raster map layers using interpolation.
  190. <h3>Hydrologic modeling toolbox</h3>
  191. Watershed modeling related modules are
  192. <a href="r.basins.fill.html">r.basins.fill</a>,
  193. <a href="r.water.outlet.html">r.water.outlet</a>,
  194. <a href="r.watershed.html">r.watershed</a>, and
  195. <a href="r.terraflow.html">r.terraflow</a>.
  196. Water flow related modules are
  197. <a href="r.carve.html">r.carve</a>,
  198. <a href="r.drain.html">r.drain</a>,
  199. <a href="r.fill.dir.html">r.fill.dir</a>,
  200. <a href="r.fillnulls.html">r.fillnulls</a>,
  201. <a href="r.flow.html">r.flow</a>, and
  202. <a href="r.topidx.html">r.topidx</a>.
  203. Flooding can be simulated with <a href="r.lake.html">r.lake</a>.
  204. Hydrologic simulation model are available as
  205. <a href="r.sim.sediment.html">r.sim.sediment</a>,
  206. <a href="r.sim.water.html">r.sim.water</a>, and
  207. <a href="r.topmodel.html">r.topmodel</a>.
  208. <h3>Raster format</h3>
  209. Raster data can be stored in GRASS as 2D or 3D grids. 2D rasters
  210. support 3 data types: 32bit signed integer, single- and double-precision
  211. floating-point. 3D rasters support only single- and double-precision
  212. floating-point. In most GRASS resources, 2D raster maps are usually
  213. called "raster", their integer data type "CELL", single-precision
  214. floating-point data type "FCELL" and double-precision floating-point
  215. "DCELL". The 3D raster map type is usually called "3D raster" but other
  216. names like "G3D", "voxel", "volume", "GRID3D" or "3d cell" are common.
  217. 3D raster's single-precision data type is most often called "float", and the
  218. double-precision one "double".
  219. <p>
  220. GRASS raster format is architecture independent and portable between
  221. 32bit and 64bit machines.
  222. <p>
  223. GRASS distinguishes NULL and zero. When working with NULL data, it is
  224. important to know that operations on NULL cells lead to NULL cells.
  225. <h3>See also</h3>
  226. <ul>
  227. <li><a href=vectorintro.html>Introduction to GRASS vector map processing</a></li>
  228. <li><a href=raster3dintro.html>Introduction to GRASS 3D raster map (voxel) processing</a></li>
  229. </ul>
  230. <HR>
  231. <P>
  232. <a href="index.html">Main index</a> - <a href="raster.html">raster index</a>
  233. - <a href="full_index.html">full index</a>
  234. </P>
  235. <P>&copy; 2008 <a href="http://grass.osgeo.org">GRASS Development Team</a></P>
  236. </body>
  237. </html>