This program outputs two or four column (with -g) data to stdout or an ASCII file. The default two column output consists of cumulative profile length (in meters) and raster value. The optional four column output consists of easting, northing, cumlative profile length (m), and raster value. Profile end or "turning" points can be set manually with the profile argument or selected interactively from the GRASS monitor by setting the -i flag. The profile resolution, or distance between profile points, is obtained from the current region resolution, or can be manually set with the res argument.

The -i flag allows the user for selecting the profile from the GRASS monitor by clicking the left mouse button along the profile; clicking the right mouse button ends the profile.

The profile parameter can be set to comma separated geographic coordinates for profile line endpoints. The interactive flag (-i) overrides this option. Alternatively the coordinate pairs can be piped from stdin, one comma separated pair per line.

The res parameter sets the distance between each profile point (resolution). The resolution must be provided in GRASS database units (i.e. decimal degrees for Lat Long databases and meters for UTM). By default r.profile uses the resolution of the current GRASS region.

The null parameter can optionally be set to change the character string representing null values.


The multi column output from r.profile is intended for easy use in other programs. The output can be piped (|) directly into other programs or saved to a file for later use. Output with geographic coordinates (-g) is compatible with and can be piped direcly into this program.
r.profile -ig input=elev.rast | output=elev.profile fs=space
The 2 column output is compatible with most plotting programs.

The optional RGB output provides the associated GRASS colour value for each profile point.


Example 1
Extract a profile with coordinates provided on the command line:
r.profile input=elev.rast output=profile.pts profile=562517,7779433,562984,7779533,563875,7779800
This will extract a profile along the track defined by the three coordinate pairs.

Example 2
Extract a profile by interactively selecting the profile route from the GRASS monitor:

r.profile -i input=elev.rast output=profile.pts
Use the left mouse button to select the profile route in the GRASS monitor. Use the right mouse button to end the profile.

Example 3
Extract a profile with coordinates provided from standard input or an external file:

First create a points file with d.where

d.where > saved.points
Then pipe the points file into r.profile
cat saved.points | r.profile input=elev.rast output=profile.pts
The advantage of this method is that the same profile points can be piped into different GRASS rasters by changing the input parameter.

With this method the coordinates must be given as space or tab separated easting and northing. Labels after these values are ignored.

Another example using d.where:

d.where | r.profile elevation.dem

Example 4
Pipe coordinates into r.profile

r.profile elevation.dem res=1000 << EOF


The profile resolution is measured exactly from the supplied end or "turning" point along the profile. The end of a profile segment will be an exact multiple of the profile resolution and will therefore not always match the end point coordinates entered for the segmanet.

To extract the numbers in scripts, following parameters can be used:

r.profile input=dgm12.5 profile=3570631,5763556 2>/dev/null
This filters out the everything except the numbers.

SEE ALSO, d.where, d.profile, r.what, r.transect, gis.m: PROFILE TOOL


Bob Covill

Last changed: $Date$