1rasterintro(1) Grass User's Manual rasterintro(1)
2
3
4
6 Raster maps in general
7 A "raster map" is a data layer consisting of a gridded array of cells.
8 It has a certain number of rows and columns, with a data point (or null
9 value indicator) in each cell. These may exist as a 2D grid or as a 3D
10 cube made up of many smaller cubes, i.e. a stack of 2D grids.
11
12 The geographic boundaries of the raster map are described by the north,
13 south, east, and west fields. These values describe the lines which
14 bound the map at its edges. These lines do NOT pass through the center
15 of the grid cells at the edge of the map, but along the edge of the map
16 itself. i.e. the geographic extent of the map is described by the
17 outer bounds of all cells within the map.
18
19 As a general rule in GRASS GIS:
20
21 1 Raster output maps have their bounds and resolution equal to
22 those of the current computational region.
23
24 2 Raster input maps are automatically cropped/padded and rescaled
25 (using nearest-neighbour resampling) to match the current
26 region.
27
28 3 Raster input maps are automatically masked if a raster map named
29 MASK exists. The MASK is only applied when reading maps from the
30 disk.
31
32 There are a few exceptions to this: r.in.* programs read the data
33 cell-for-cell, with no resampling. When reading non-georeferenced data,
34 the imported map will usually have its lower-left corner at (0,0) in
35 the location’s coordinate system; the user needs to use r.region to
36 "place" the imported map.
37
38 Some programs which need to perform specific types of resampling (e.g.
39 r.resamp.rst) read the input maps at their original resolution then do
40 the resampling themselves.
41
42 r.proj has to deal with two regions (source and destination) simultane‐
43 ously; both will have an impact upon the final result.
44
45 Raster import and export
46 The module r.in.gdal offers a common interface for many different
47 raster formats. Additionally, it also offers options such as on-the-fly
48 location creation or extension of the default region to match the
49 extent of the imported raster map. For special cases, other import
50 modules are available. The full map is always imported.
51
52 For importing scanned maps, the user will need to create a x,y-loca‐
53 tion, scan the map in the desired resolution and save it into an appro‐
54 priate raster format (e.g. tiff, jpeg, png, pbm) and then use r.in.gdal
55 to import it. Based on reference points the scanned map can be recified
56 to obtain geocoded data.
57
58 Raster maps are exported with r.out.gdal into common formats. Also
59 r.out.bin, r.out.vtk, r.out.ascii and other export modules are avail‐
60 able. They export the data according to the current region settings. If
61 those differ from the original map, the map is resampled on the fly
62 (nearest neighbor algorithm). In other words, the output will have as
63 many rows and columns as the current region. To export maps with vari‐
64 ous grid spacings (e.g, 500x500 or 200x500), you can just change the
65 region resolution with g.region and then export the map. The resampling
66 is done with nearest neighbor algorithm in this case. If you want some
67 other form of resampling, first change the region, then explicitly
68 resample the map with e.g. r.resamp.interp or r.resamp.stats, then
69 export the resampled map.
70
71 GRASS GIS raster map exchange between different locations (same projec‐
72 tion) can be done in a lossless way using the r.pack and r.unpack mod‐
73 ules.
74
75 Metadata
76 The r.info module displays general information about a map such as
77 region extent, data range, data type, creation history, and other meta‐
78 data. Metadata such as map title, units, vertical datum etc. can be
79 updated with r.support. Timestamps are managed with r.timestamp. Region
80 extent and resolution are mangaged with r.region.
81
82 Raster map operations
83 Resampling methods and interpolation methods
84 GRASS raster map processing is always performed in the current region
85 settings (see g.region), i.e. the current region extent and current
86 raster resolution is used. If the resolution differs from that of the
87 input raster map(s), on-the-fly resampling is performed (nearest neigh‐
88 bor resampling). If this is not desired, the input map(s) has/have to
89 be resampled beforehand with one of the dedicated modules.
90
91 The built-in nearest-neighbour resampling of raster data calculates the
92 centre of each region cell, and takes the value of the raster cell in
93 which that point falls.
94
95 If the point falls exactly upon a grid line, the exact result will be
96 determined by the direction of any rounding error. One consequence of
97 this is that downsampling by a factor which is an even integer will
98 always sample exactly on the boundary between cells, meaning that the
99 result is ill-defined.
100
101 The following modules are available for reinterpolation of "filled"
102 raster maps (continuous data) to a different resolution:
103
104 · r.resample uses the built-in resampling, so it should produce
105 identical results as the on-the-fly resampling done via the
106 raster import modules.
107
108 · r.resamp.interp Resampling with nearest neighbor, bilinear, and
109 bicubic method: method=nearest uses the same algorithm as
110 r.resample, but not the same code, so it may not produce iden‐
111 tical results in cases which are decided by the rounding of
112 floating-point numbers.
113 For r.resamp.interp method=bilinear and method=bicubic, the
114 raster values are treated as samples at each raster cell’s cen‐
115 tre, defining a piecewise-continuous surface. The resulting
116 raster values are obtained by sampling the surface at each
117 region cell’s centre. As the algorithm only interpolates, and
118 doesn’t extrapolate, a margin of 0.5 (for bilinear) or 1.5 (for
119 bicubic) cells is lost from the extent of the original raster.
120 Any samples taken within this margin will be null.
121
122 · r.resamp.rst Regularized Spline with Tension (RST) interpola‐
123 tion 2D: Behaves similarly, i.e. it computes a surface assuming
124 that the values are samples at each raster cell’s centre, and
125 samples the surface at each region cell’s centre.
126
127 · r.resamp.bspline Bicubic or bilinear spline interpolation with
128 Tykhonov regularization.
129
130 · For r.resamp.stats without -w, the value of each region cell is
131 the chosen aggregate of the values from all of the raster cells
132 whose centres fall within the bounds of the region cell.
133 With -w, the samples are weighted according to the proportion
134 of the raster cell which falls within the bounds of the region
135 cell, so the result is normally unaffected by rounding error (a
136 minuscule difference in the position of the boundary results in
137 the addition or subtraction of a sample weighted by a minuscule
138 factor; also, The min and max aggregates can’t use weights, so
139 -w has no effect for those).
140
141 · r.fillnulls for Regularized Spline with Tension (RST) interpo‐
142 lation 2D for hole filling (e.g., SRTM DEM)
143
144 Furthermore, there are modules available for reinterpolation of
145 "sparse" (scattered points or lines) maps:
146
147 · Inverse distance weighted average (IDW) interpolation
148 (r.surf.idw)
149
150 · Interpolating from contour lines (r.contour)
151
152 · Various vector modules for interpolation
153 For Lidar and similar data, r.in.lidar and r.in.xyz support loading and
154 binning of ungridded x,y,z ASCII data into a new raster map. The user
155 may choose from a variety of statistical methods in creating the new
156 raster map.
157
158 Otherwise, for interpolation of scattered data, use the v.surf.* set of
159 modules.
160
161 Raster MASKs
162 If a raster map named "MASK" exists, most GRASS raster modules will
163 operate only on data falling inside the masked area, and treat any data
164 falling outside of the mask as if its value were NULL. The mask is only
165 applied when reading an existing GRASS raster map, for example when
166 used in a module as an input map.
167
168 The mask is read as an integer map. If MASK is actually a float‐
169 ing-point map, the values will be converted to integers using the map’s
170 quantisation rules (this defaults to round-to-nearest, but can be
171 changed with r.quant).
172
173 (see r.mask)
174
175 Raster map statistics
176 A couple of commands are available to calculate local statistics
177 (r.neighbors), and global statistics (r.statistics, r.surf.area). Pro‐
178 files and transects can be generated (d.profile, r.profile, r.transect)
179 as well as histograms (d.histogram) and polar diagrams (d.polar). Uni‐
180 variate statistics (r.univar) and reports are also available
181 (r.report,r.stats, r.volume).
182
183 Raster map algebra and aggregation
184 The r.mapcalc command provides raster map algebra methods. The
185 r.resamp.stats command resamples raster map layers using various aggre‐
186 gation methods, the r.statistics command aggregates one map based on a
187 second map. r.resamp.interp resamples raster map layers using interpo‐
188 lation.
189
190 Regression analysis
191 Both linear (r.regression.line) and multiple regression (r.regres‐
192 sion.multi) are supported.
193
194 Hydrologic modeling toolbox
195 Watershed modeling related modules are r.basins.fill, r.water.outlet,
196 r.watershed, and r.terraflow. Water flow related modules are r.carve,
197 r.drain, r.fill.dir, r.fillnulls, r.flow, and r.topidx. Flooding can
198 be simulated with r.lake. Hydrologic simulation model are available as
199 r.sim.sediment, r.sim.water, and r.topmodel.
200
201 Raster format
202 In GRASS GIS, raster data can be stored as 2D or 3D grids.
203
204 2D raster maps
205 2D rasters support three data types (for technical details, please
206 refer to the Wiki article GRASS raster semantics):
207
208 · 32bit signed integer (CELL),
209
210 · single-precision floating-point (FCELL), and
211
212 · double-precision floating-point (DCELL).
213 In most GRASS GIS resources, 2D raster maps are usually called "raster"
214 maps.
215
216 3D raster maps
217 The 3D raster map type is usually called "3D raster" but other names
218 like "RASTER3D", "voxel", "volume", "GRID3D" or "3d cell" are yet com‐
219 mon. 3D rasters support only single- and double-precision float‐
220 ing-point. 3D raster’s single-precision data type is most often called
221 "float", and the double-precision one "double".
222
223 No-data management and data portability
224 GRASS GIS distinguishes NULL and zero. When working with NULL data, it
225 is important to know that operations on NULL cells lead to NULL cells.
226
227 The GRASS GIS raster format is architecture independent and portable
228 between 32bit and 64bit machines.
229
230 Raster compression
231 All GRASS GIS raster map types are by default ZLIB compressed, i.e.
232 using ZLIB’s deflate algorithm. Through the environment variable
233 GRASS_COMPRESSOR the compression method can be set to RLE, ZLIB, LZ4,
234 or BZIP2.
235
236 Important: the NULL file compression must be explicitly turned on with
237 export GRASS_COMPRESS_NULLS=1 - such raster maps can then only be
238 opened with GRASS GIS 7.2.0 or later. NULL file compression can be man‐
239 aged with r.null -z.
240
241 Integer (CELL type) raster maps can be compressed with RLE if the envi‐
242 ronment variable GRASS_INT_ZLIB exists and is set to value 0. However,
243 this is not recommended.
244
245 Floating point (FCELL, DCELL) raster maps never use RLE compression;
246 they are either compressed with ZLIB, LZ4, BZIP2 or are uncompressed.
247
248 RLE
249 DEPRECATED Run-Length Encoding, poor compression ratio but fast. It
250 is kept for backwards compatibility to read raster maps created
251 with GRASS 6. It is only used for raster maps of type CELL. FCELL
252 and DCELL maps are never and have never been compressed with RLE.
253
254 ZLIB
255 ZLIB’s deflate is the default compression method for all raster
256 maps. GRASS GIS 7 uses by default 1 as ZLIB compression level which
257 is the best compromise between speed and compression ratio, also
258 when compared to other available compression methods. Valid levels
259 are in the range [1, 9] and can be set with the environment vari‐
260 able GRASS_ZLIB_LEVEL.
261
262 LZ4
263 LZ4 is a very fast compression method, about as fast as no compres‐
264 sion. Decompression is also very fast. The compression ratio is
265 generally higher than for RLE but worse than for ZLIB. LZ4 is rec‐
266 ommended if disk space is not a limiting factor.
267
268 BZIP2
269 BZIP2 can provide compression ratios much higher than the other
270 methods, but only for large raster maps (> 10000 columns). For
271 large raster maps, disk space consumption can be reduced by 30 -
272 50% when using BZIP2 instead of ZLIB’s deflate. BZIP2 is the slow‐
273 est compression and decompression method. However, if reading from
274 / writing to a storage device is the limiting factor, BZIP2 com‐
275 pression can speed up raster map processing. Be aware that for
276 smaller raster maps, BZIP2 compression ratio can be worse than
277 other compression methods.
278
279 In the internal cellhd file, the value for "compressed" is 1 for RLE, 2
280 for ZLIB, 3 for LZ4, and 4 for BZIP2.
281
282 Obviously, decompression is controlled by the raster map’s compression,
283 not the environment variable.
284
285 See also
286 · Introduction into 3D raster data (voxel) processing
287
288 · Introduction into vector data processing
289
290 · Introduction into image processing
291
292 · Introduction into temporal data processing
293
294 · Database management
295
296 · Projections and spatial transformations
297
299 Available at: Raster data processing in GRASS GIS source code (history)
300
301 Main index | Raster index | Topics index | Keywords index | Graphical
302 index | Full index
303
304 © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
305
306
307
308GRASS 7.4.4 rasterintro(1)