[GRASS-user] d.out.file now does GeoTIFFs
Glynn Clements
glynn at gclements.plus.com
Thu Oct 30 13:11:47 EDT 2008
Hamish wrote:
> slight contributing motivation:
> I am not sure of a good way to merge raster maps with different color
> tables (imagery data). In the past I have tried 'r.mapcalc r# g# b#'
> operators+r.patch, d.out.png+r.in.gdal+r.region, neither was much fun.
> I guess g.pnmcomp could help but I fear the added complexity of passing
> the data through the display drivers will introduce noise. Perhaps
> gdal_merge.py? (see r.in.wms mess WRT merging paletted GIF images)
Maybe r.composite should have an option to use a single input map
rather than separate channels? IOW, convert the input map (whether
integer or FP) to an integer map whose categories directly correspond
to the input map's colours.
It could easily be implemented as a script:
in=$GIS_OPT_INPUT
out=$GIS_OPT_OUTPUT
tmp=tmp.colors.$$
r.mapcalc <<EOF
$tmp.r = r#$in
$tmp.g = g#$in
$tmp.b = b#$in
EOF
r.composite r=$tmp.r g=$tmp.g b=$tmp.g levels=256 output=$tmp.c
r.mapcalc "$out = if(isnull($in),null(),$tmp.c)"
r.colors $out raster=$tmp.c
g.remove rast=$tmp.r,$tmp.g,$tmp.b,$tmp.c
Actually, the first r.mapcalc should probably be isolated into a
separate "uncomposite" script, which split a colourised map into R/G/B
channels:
r.mapcalc <<EOF
$out.r = if(isnull($in),null(),r#$in)
$out.g = if(isnull($in),null(),g#$in)
$out.b = if(isnull($in),null(),b#$in)
EOF
Also, a script to "collapse" a rule-based colour table (as generated
by e.g. r.composite) to a category-based table, using r.category and
r.what.color. Left as an exercise for the reader.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list