[GRASS-user] r.mapcalc changes color table

Glynn Clements glynn at gclements.plus.com
Thu Nov 26 20:27:29 EST 2009


Tim Michelsen wrote:

> I have a large georeferenced digital map.
> 
> I successfully imported it into GRASS.
> 
> Now I would like to "cut" only a small rectangle -- my investigation
> area -- out of this large map.
> 
> I used the following approach:
> 
> 1) import the TIFF
> 2) select the part of interest in the GRASS monitor
> 3) set the zoomed area as region (monitor tools)
> 4) create a boundary vector: v.in.region
> 5) convert boundary raster to a raster v.to.rast
> 6) use r.mapcalc to cut: r.mapcalc "cut=if(boundary_raster, large_map,
> null())"

Replace step 6 with:

	g.copy rast=boundary_raster,MASK
	r.resample input=large_map output=cut
	g.remove rast=MASK

> This works well for the cutting. But the color table of the large input
> map is lost resulting in a strange coloring.
> Opened in QGIS, it shows me that there is a "color map" associated with
> the layer.
> How do I get the same color table in the r.mapcalc result?

You can copy the colour table over with e.g.:

	r.colors map=cut raster=large_map

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list