Author: Markus Neteler/GRASS Development Team

## Raster data processing in GRASS GIS

### Raster maps in general

The geographic boundaries of the raster file 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.

There are a few exceptions to this: `r.in.*` 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; ther 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

The module r.in.gdal 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 r.in.gdal to import it. Based on reference points the scanned map can be recified to obtain geocoded data.

### 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 map statistics

A couple of commands are available to calculate local statistics (r.neighbors), and global statistics (r.statistics, r.surf.area, 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.report,r.stats, r.volume).

### Raster map algebra and aggregation

The r.mapcalc command provides raster map algebra methods. The r.average command aggregates one map based on a second map.

### Raster map resampling and interpolation methods

GRASS offers various raster resampling and interpolation methods:

- Resampling with nearest neighbor and bilinear method (r.resample, r.bilinear)
- Inverse distance weighted average (IDW) interpolation (r.surf.idw and r.surf.idw2)
- Regularized spline with tension (RST) interpolation 2D (r.resamp.rst)
- Interpolating from contour lines (r.contour)

### 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.

### See also

- Introduction to GRASS vector map processing
- Introduction to GRASS 3D raster map (voxel) processing

Main index - raster index - full index