GRASS GIS color maps
 

  • You can change or create raster color maps with the r.colors module. See the r.colors help page.
  • You can import GMT (Generic Mapping Tools) color maps with the r.cpt2grass addon module. It can save the converted rules to a text file suitable for r.colors or automatically apply the color table to a raster map directly. Here is an online colormap repository with many fine GMT gradients.
  • Colors are generally given as a color name (e.g. red, blue, indigo), the word "none", or a red:green:blue triplet, where RGB component values range from 0-255 (e.g. 0:127:255).
  • GRASS vector map features linked to an associated GRASSRGB attribute column may be colored using R:G:B triplets (see the d.vect and ps.map help pages), and the d.vect.thematic module can be used to color by value. It is hoped that in future d.vect can be expanded to allow thematic vector mapping to work directly with the GRASS color rules subsystem without the need for the GRASSRGB data column and associated overhead.
  • Rules for importing Ocean Color satellite data from MODIS Aqua can be found
  • The rest of this page deals with color maps dynamically created from raster map data. The r.colors module makes it easy to set up both smooth and banded color rules based on exact values or percentage of data range. In GRASS version 6.3 and newer there are also options to do logarithmic scaling, histogram equalization, and inverting the color rules. This allows you to create interesting visualizations of your raster data without needing to waste disk space by keeping multiple copies of the map on the disk or going to the trouble of setting up reclass maps. An example of this is presented here in the r.colors.stddev module. It is simply a UNIX shell script which calculates statistics about the map with the r.univar module, then applies dynamic color rules based on that information.
  • r.colors.stddev creates a color map using standard deviation color breaks. The default usage creates a color map with two standard deviations below the mean colored blue, the mean colored white, and two standard deviations above the mean colored red. In between is a linear gradient. The -b flag can be used to switch to module to use a green/yellow/red/black color banded display (representing values falling within one, two, three, and beyond standard deviations). The -z flag can be used to force the center to be zero to better represent magnitude of difference maps. To do this it creates a temporary map containing the absolute values of differences, then calculates the area under the curve containing 1,2,3 standard deviations. A normal distribution is blithely assumed; improvements to the script from stats gurus are welcomed.

SPEARFISH
South Dakota

elevation.dem

elevation.dem with histogram

'r.univar elevation.dem'

minimum: 1066
maximum: 1840
range: 774
mean: 1353.67
standard deviation: 177.041


Deviation from mean value

'r.colors.stddev elevation.dem' with histogram

'r.colors.stddev -b elevation.dem' with histogram


Elevation model differences map

Showing the differences between the USGS 1:24,000 scale
DEM map series quadrangles (elevation.dem) and the
USGS National Elevation Dataset (NED) 1999 (elevation.10m).

r.mapcalc "elev.diff = elevation.dem - elevation.10m"

Note 10m raster resampled to 30m using g.region resolution rules
(i.e. nearest cell center neighbor)


Equalized BCYR differences map with histogram
'r.colors -e elev.diff color=bcyr'

'r.univar elev.diff'

minimum: -33.1195
maximum: 73.6345
range: 106.754
mean: 5.29799
mean of absolute values: 7.1458
standard deviation: 7.57461


Zero centered deviation map with histogram
'r.colors.stddev -z elev.diff'

Note d.histogram x-axis tick labels are not very useful with floating point maps (volunteer needed).
The white band is centered at 0.0; skew is due to mean(elev.dem) > mean(elev.10m).
Dark blue and red represent two standard deviations away from zero.



Zero centered deviation map using standard deviation bands
'r.colors.stddev -z -b elev.diff'


Histogram showing absolute differences from zero with standard deviation bands
r.mapcalc "elev.diff_abs = abs(elev.diff)"
r.colors.stddev -z -b elev.diff_abs

Note this is what r.colors.stddev uses for zero-centered calculations.

'r.univar -e elev.diff_abs percentile=68'

minimum: 0
maximum: 73.6345
mean: 7.1458
standard deviation: 5.86352
1st quartile: 2.68347
median (odd number of cells): 5.72192
68th percentile: 8.61414
3rd quartile: 10.1084
95th percentile: 18.6869
99th percentile: 25.6603