[GRASS-user] Label difficulties
Glynn Clements
glynn at gclements.plus.com
Wed Aug 29 22:18:49 EDT 2007
Adam Dershowitz wrote:
> you and a few others suggested that I could use r.blend. Initially
> it did not work as expected. It turns out that my top map was
> smaller than my basemap and that r.blend was still blending beyond
> the border of the top map, so that the bottom map looked washed out.
> I ended up editing r.blend to make it work as I expected. I am not
> sure who this should go to, but let me suggest the following change
> to r.blend:
> Replace this:
> r.mapcalc "$GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT +
> (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND"
> r.mapcalc "$GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT +
> (1.0 - .$GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND"
> r.mapcalc "$GIS_OPT_OUTPUT.b = b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT +
> (1.0 - .$GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND"
>
> with this:
>
> r.mapcalc "$GIS_OPT_OUTPUT.r = if(isnull($GIS_OPT_FIRST),r#
> $GIS_OPT_SECOND, r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .
> $GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND)"
> r.mapcalc "$GIS_OPT_OUTPUT.g = if(isnull($GIS_OPT_FIRST),g#
> $GIS_OPT_SECOND, g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .
> $GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND)"
> r.mapcalc "$GIS_OPT_OUTPUT.b = if(isnull($GIS_OPT_FIRST),b#
> $GIS_OPT_SECOND, b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .
> $GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND)"
>
> That way, in places where the top map is null it just leaves the
> bottom map alone.
I suggest:
$GIS_OPT_OUTPUT.r = eval(\
n1 = isnull($GIS_OPT_FIRST), n2 = isnull($GIS_OPT_SECOND),\
k1 = n1 ? 0 : n2 ? 1 : $GIS_OPT_PERCENT/100.0,\
k2 = n2 ? 0 : n1 ? 1 : 1.0 - $GIS_OPT_PERCENT/100.0,\
k1 * r#$GIS_OPT_FIRST + k2 * r#$GIS_OPT_SECOND)
$GIS_OPT_OUTPUT.g = k1 * g#$GIS_OPT_FIRST + k2 * g#$GIS_OPT_SECOND
$GIS_OPT_OUTPUT.b = k1 * b#$GIS_OPT_FIRST + k2 * b#$GIS_OPT_SECOND
Actually, I should probably get rid of the requirement that each
statement must be an assignment; the above would be more clear if the
eval() was separate to the .r calculation.
> Is there a particular developer or other list that this suggestion
> should be sent to?
This is the right place.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list