[GRASS-user] composite raster maps

Glynn Clements glynn at gclements.plus.com
Tue Nov 26 11:07:58 PST 2013

Markus Metz wrote:

> > I just realize I've used r.composite for ages without wondering how I
> > could perform the reverse task. The thing is I ran r.composite on a 3
> > band geotiff orthoimage, dropped the initial .red, .green and .blue
> > rasters, and I would need them now in order to run r.out.vtk with the
> > rgbmaps argument. Dummy...
> You can use the # operator of r.mapcalc:
> r.mapcalc "map.red = r#map"
> r.mapcalc "map.green = g#map"
> r.mapcalc "map.blue = b#map"

Note that GRASS 7 has the r.rgb script which does just this.

Also, note that an r.composite+r.rgb round-trip normally loses
accuracy. By default, the maps generated by r.composite only use 32
levels for each component (equivalent to a 15-bpp image).

You can avoid this with "r.composite ... levels=256", but the
resulting maps will have much larger colour tables (65536 rules rather
than 1024), which can make certain operations significantly slower.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list