GRASS logo

Raster data processing in GRASS GIS

Raster maps in general

The geographic boundaries of the raster map are described by the north, south, east, and west fields. These values describe the lines which bound the map at its edges. These lines do NOT pass through the center of the grid cells at the edge of the map, but along the edge of the map itself.

As a general rule in GRASS:

  1. Raster output maps have their bounds and resolution equal to those of the current region.
  2. Raster input maps are automatically cropped/padded and rescaled (using nearest-neighbour resampling) to match the current region.
  3. Raster input maps are automatically masked if a raster map named MASK exists.
There are a few exceptions to this:* programs read the data cell-for-cell, with no resampling. When reading non-georeferenced data, the imported map will usually have its lower-left corner at (0,0) in the location's coordinate system; the user needs to use r.region to "place" the imported map.

Some programs which need to perform specific types of resampling (e.g. r.resamp.rst) read the input maps at their original resolution then do the resampling themselves.

r.proj has to deal with two regions (source and destination) simultaneously; both will have an impact upon the final result.

Raster import and export

The module offers a common interface for many different raster formats. Additionally, it also offers options such as on-the-fly location creation or extension of the default region to match the extent of the imported raster map. For special cases, other import modules are available. Always the full map is imported.

For importing scanned maps, the user will need to create a x,y-location, scan the map in the desired resolution and save it into an appropriate raster format (e.g. tiff, jpeg, png, pbm) and then use to import it. Based on reference points the scanned map can be recified to obtain geocoded data.

Raster maps are exported with r.out.gdal into common formats. Also r.out.bin, r.out.vtk and other export modules are available.


The module displays general information about a map such as region extent, data range, data type, creation history, and other metadata. Metadata such as map title, units, vertical datum etc. can be updated with Timestamps are managed with r.timestamp. Region extent and resolution are mangaged with r.region.

Raster map operations

GRASS raster map processing is always performed in the current region settings (see g.region), i.e. the current region extent and current raster resolution is used. If the resolution differs from that of the input raster map(s), on-the-fly resampling is performed (nearest neighbor resampling). If this is not desired, the input map(s) has/have to be resampled beforehand with one of the dedicated modules.

Raster MASKs

If a raster map named "MASK" exists, most GRASS raster modules will operate only on data falling inside the masked area, and treat any data falling outside of the mask as if its value were NULL. The mask is only applied when reading an existing GRASS raster map, for example when used in a module as an input map.

The mask is read as an integer map. If MASK is actually a floating-point map, the values will be converted to integers using the map's quantisation rules (this defaults to round-to-nearest, but can be changed with r.quant).

(see r.mask)

Raster map statistics

A couple of commands are available to calculate local statistics (r.neighbors), and global statistics (r.statistics,, r.sum). Profiles and transects can be generated (d.profile, r.profile, r.transect) as well as histograms (d.histogram) and polar diagrams (d.polar). Univariate statistics (r.univar) and reports are also available (,r.stats, r.volume).

Raster map algebra and aggregation

The r.mapcalc command provides raster map algebra methods. The r.resamp.stats command resamples raster map layers using various aggregation methods, the r.average command aggregates one map based on a second map. r.resamp.interp resamples raster map layers using interpolation.

Raster map resampling and interpolation methods

GRASS offers various raster resampling and interpolation methods. There are available modules for reinterpolation of "filled" raster maps (continuous data) to a different resolution: Furthermore, there are modules available for reinterpolation of "sparse" (scattered points or lines) maps: For Lidar and similar data, supports loading and binning of ungridded x,y,z ASCII data into a new raster map. The user may choose from a variety of statistical methods in creating the new raster.

Otherwise, for interpolation of scattered data, use the* set of modules.

Hydrologic modeling toolbox

Watershed modeling related modules are r.basins.fill, r.water.outlet, r.watershed, and r.terraflow. Water flow related modules are r.carve, r.drain, r.fill.dir, r.fillnulls, r.flow, and r.topidx. Flooding can be simulated with r.lake. Hydrologic simulation model are available as r.sim.sediment, r.sim.water, and r.topmodel.

Raster format

Raster data can be stored in GRASS as 2D or 3D grids. 2D rasters support 3 data types: 32bit signed integer, single- and double-precision floating-point. 3D rasters support only single- and double-precision floating-point. In most GRASS resources, 2D raster maps are usually called "raster", their integer data type "CELL", single-precision floating-point data type "FCELL" and double-precision floating-point "DCELL". The 3D raster map type is usually called "3D raster" but other names like "G3D", "voxel", "volume", "GRID3D" or "3d cell" are common. 3D raster's single-precision data type is most often called "float", and the double-precision one "double".

GRASS raster format is architecture independent and portable between 32bit and 64bit machines.

GRASS distinguishes NULL and zero. When working with NULL data, it is important to know that operations on NULL cells lead to NULL cells.

See also

Main index - raster index - full index

© 2008 GRASS Development Team