1rasterintro(1)              GRASS GIS User's Manual             rasterintro(1)
2
3
4

Raster data processing in GRASS GIS

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 re‐
26              gion.
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 ex‐
49       tent of the imported raster map.  For special cases, other import  mod‐
50       ules 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  re‐
68       sample  the  map with e.g.  r.resamp.interp or r.resamp.stats, then ex‐
69       port 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  re‐
77       gion  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 al‐
98       ways sample exactly on the boundary between cells, meaning that the re‐
99       sult 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 r.re‐
110               sample, but not the same code, so it may not produce  identical
111               results  in  cases  which are decided by the rounding of float‐
112               ing-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 re‐
117               gion 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.pdal 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 op‐
163       erate  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 (r.re‐
181       port,r.stats, r.volume).  Since r.univar may be slow for extended  sta‐
182       tistics these can be calculated using r.stats.quantile. Without a zones
183       input raster, the r.quantile module will be  significantly  more  effi‐
184       cient for calculating percentiles with large maps. For calculating uni‐
185       variate statistics from a raster map based on vector  polygon  map  and
186       upload  statistics to new attribute columns, see v.rast.stats. Category
187       or object oriented statistics can be computed with  r.statistics.   For
188       floating-point   cover  map  support  for  this,  see  the  alternative
189       r.stats.zonal.  For  quantile  calculations  with  support  for  float‐
190       ing-point cover maps, see the alternative r.stats.quantile.
191
192   Raster map algebra and aggregation
193       The  r.mapcalc  command provides raster map algebra methods.  The r.re‐
194       samp.stats command resamples raster map layers using  various  aggrega‐
195       tion  methods,  the  r.statistics command aggregates one map based on a
196       second map.  r.resamp.interp resamples raster map layers using interpo‐
197       lation.
198
199   Regression analysis
200       Both  linear  (r.regression.line)  and  multiple  regression (r.regres‐
201       sion.multi) are supported.
202
203   Hydrologic modeling toolbox
204       Watershed modeling related modules are  r.basins.fill,  r.water.outlet,
205       r.watershed,  and r.terraflow.  Water flow related modules are r.carve,
206       r.drain, r.fill.dir, r.fillnulls, r.flow, and r.topidx.   Flooding  can
207       be simulated with r.lake.  Hydrologic simulation model are available as
208       r.sim.sediment, r.sim.water, and r.topmodel.
209
210   Raster format
211       In GRASS GIS, raster data can be stored as 2D or 3D grids.
212
213   2D raster maps
214       2D rasters support three data types (for technical details, please  re‐
215       fer to the Wiki article GRASS raster semantics):
216
217           •   32bit signed integer (CELL),
218
219           •   single-precision floating-point (FCELL), and
220
221           •   double-precision floating-point (DCELL).
222       In most GRASS GIS resources, 2D raster maps are usually called "raster"
223       maps.
224
225   3D raster maps
226       The 3D raster map type is usually called "3D raster"  but  other  names
227       like  "RASTER3D", "voxel", "volume", "GRID3D" or "3d cell" are yet com‐
228       mon.  3D rasters  support  only  single-  and  double-precision  float‐
229       ing-point.  3D raster’s single-precision data type is most often called
230       "float", and the double-precision one "double".
231
232   No-data management and data portability
233       GRASS GIS distinguishes NULL and zero. When working with NULL data,  it
234       is important to know that operations on NULL cells lead to NULL cells.
235
236       The  GRASS  GIS  raster format is architecture independent and portable
237       between 32bit and 64bit machines.
238
239   Raster compression
240       All GRASS GIS raster map types are by default ZSTD compressed if avail‐
241       able,  otherwise  ZLIB  compressed.  Through  the  environment variable
242       GRASS_COMPRESSOR the compression method can be set to RLE,  ZLIB,  LZ4,
243       BZIP2, or ZSTD.
244
245       Important:  the  NULL  file  compression  can be turned off with export
246       GRASS_COMPRESS_NULLS=0. Raster maps with NULL file compression can only
247       be  opened  with  GRASS GIS 7.2.0 or later. NULL file compression for a
248       particular raster map can be managed with r.null -z.
249
250       Integer (CELL type) raster maps can be compressed with RLE if the envi‐
251       ronment  variable  GRASS_COMPRESSOR  exists and is set to RLE. However,
252       this is not recommended.
253
254       Floating point (FCELL, DCELL) raster maps never  use  RLE  compression;
255       they  are  either  compressed with ZLIB, LZ4, BZIP2, ZSTD or are uncom‐
256       pressed.
257
258       RLE
259           DEPRECATED Run-Length Encoding, poor compression ratio but fast. It
260           is  kept  for  backwards  compatibility to read raster maps created
261           with GRASS 6. It is only used for raster maps of type CELL.   FCELL
262           and DCELL maps are never and have never been compressed with RLE.
263
264       ZLIB
265           ZLIB’s  deflate  is  the  default compression method for all raster
266           maps, if ZSTD is not available. GRASS GIS 8 uses by  default  1  as
267           ZLIB  compression  level which is the best compromise between speed
268           and compression ratio, also when compared to other  available  com‐
269           pression  methods.  Valid levels are in the range [1, 9] and can be
270           set with the environment variable GRASS_ZLIB_LEVEL.
271
272       LZ4
273           LZ4 is a very fast compression method, about as fast as no compres‐
274           sion.  Decompression  is  also  very fast. The compression ratio is
275           generally higher than for RLE but worse than for ZLIB. LZ4 is  rec‐
276           ommended if disk space is not a limiting factor.
277
278       BZIP2
279           BZIP2  can  provide  compression  ratios much higher than the other
280           methods, but only for large raster  maps  (>  10000  columns).  For
281           large  raster  maps,  disk space consumption can be reduced by 30 -
282           50% when using BZIP2 instead of ZLIB’s deflate. BZIP2 is the  slow‐
283           est  compression and decompression method. However, if reading from
284           / writing to a storage device is the limiting  factor,  BZIP2  com‐
285           pression  can  speed  up  raster  map processing. Be aware that for
286           smaller raster maps, BZIP2 compression  ratio  can  be  worse  than
287           other compression methods.
288
289       ZSTD
290           ZSTD  (Zstandard)  provides compression ratios higher than ZLIB but
291           lower than BZIP2 (for large data). ZSTD compresses up to 4x  faster
292           than  ZLIB,  and  usually decompresses 6x faster than ZLIB. ZSTD is
293           the default compression method if available.
294
295       In the internal cellhd file, the value for "compressed" is 1 for RLE, 2
296       for ZLIB, 3 for LZ4,4 for BZIP2, and 5 for ZSTD.
297
298       Obviously, decompression is controlled by the raster map’s compression,
299       not the environment variable.
300
301   See also
302           •   Introduction into 3D raster data (voxel) processing
303
304           •   Introduction into vector data processing
305
306           •   Introduction into image processing
307
308           •   Introduction into temporal data processing
309
310           •   Database management
311
312           •   Projections and spatial transformations
313

SOURCE CODE

315       Available at: Raster data processing in GRASS GIS source code (history)
316
317       Accessed: Saturday Jan 21 17:40:37 2023
318
319       Main index | Raster index | Topics index | Keywords index  |  Graphical
320       index | Full index
321
322       © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
323
324
325
326GRASS 8.2.1                                                     rasterintro(1)
Impressum