[GRASS-user] How to set layer opacity in maps created from command line? (Nikos Alexandris)

I think that r.blend may accomplish what I need, in terms of compositing rasters to achieve the effect of partial transparency in a layer. It is not clear to me how this will work when one or more of the layers that I want to composite has rgb channels and so is represented by three separate raster maps (one for each channel) in the mapset. Do I need to create an image group (i.group) of the three channels and use the group's name as 'first' or 'second' parameter for r.blend?

The documentation for r.blend seems to indicate that it can only blend two rasters at a time.

Message: 4
Date: Thu, 3 Oct 2013 11:44:38 -0600
From: Gregory Penn <gregory.penn@gmail.com>
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] How to set layer opacity in maps created from
  command line?
Message-ID: <B66987DB-8098-4B6E-9282-6EB3B6CFCE7D@gmail.com>
Content-Type: text/plain; charset=us-ascii

I am attempting to create maps from the command line, which are composites of several raster and vector layers. In order to visualize the data effectively, I need to vary the opacity of the layers. I have found that this is simple to achieve in the wxGUI, but the GUI does not display the underlying module call as it does with many other commands. A little Googling helped me to discover a module called g.pnmcomp, which was apparently used by the old Tcl/Tk GUI for managing layer opacity, but that module appears not to be intended for end users and I suspect that there is an easier and more direct way to achieve my desired results.

The process by which I'm creating my maps is essentially this sequence of commands (is there a better approach?):

g.region rast=region_raster.tif
d.mon start=PNG
d.rast map=some_raster.tif
d.rast map=another_raster.tif
d.vect map=some_vector.shp
d.mon stop=PNG

It seems to me that either d.mon or the PNG driver is doing the compositing and so would handle the opacity of the layers, but I can't find any documentation of how to specify values for opacity. This is surprising to me because it seems that what I'm trying to do is such a basic and commonly used operation in creating maps. What am I missing?

------------------------------

Message: 5
Date: Thu, 03 Oct 2013 22:03:27 +0300
From: Nikos Alexandris <nik@nikosalexandris.net>
To: grass-user@lists.osgeo.org
Cc: Gregory Penn <gregory.penn@gmail.com>
Subject: Re: [GRASS-user] How to set layer opacity in maps created
  from command line?
Message-ID: <2374263.A5DhYUQC8g@resilience>
Content-Type: text/plain; charset="us-ascii"

On Thursday 03 of October 2013 11:44:38 Gregory Penn wrote:

I am attempting to create maps from the command line, which are composites
of several raster and vector layers.

Working on GRASS 6.x or 7?

In order to visualize the data effectively, I need to vary the opacity of
the layers. I have found that this is simple to achieve in the wxGUI, but
the GUI does not display the underlying module call as it does with many
other commands. A little Googling helped me to discover a module called
g.pnmcomp, which was apparently used by the old Tcl/Tk GUI for managing
layer opacity, but that module appears not to be intended for end users and
I suspect that there is an easier and more direct way to achieve my desired
results.

Check r.blend: <http://grass.osgeo.org/grass64/manuals/r.blend.html&gt;,
<http://grass.osgeo.org/grass70/manuals/r.blend.html&gt;\. The latter features a
"-c" flag, which does... "Combine resulting R,G,B layers into single output
map".

The process by which I'm creating my maps is essentially this sequence of
commands (is there a better approach?):

g.region rast=region_raster.tif
d.mon start=PNG
d.rast map=some_raster.tif
d.rast map=another_raster.tif
d.vect map=some_vector.shp
d.mon stop=PNG

Ah, this is GRASS6.x then. I think you can still blend maps and then maybe use
d.out.png to export? See
<http://grass.osgeo.org/grass64/manuals/d.out.png.html&gt;\.

It seems to me that either d.mon or the PNG driver is doing the compositing
and so would handle the opacity of the layers, but I can't find any
documentation of how to specify values for opacity. This is surprising to
me because it seems that what I'm trying to do is such a basic and commonly
used operation in creating maps. What am I missing?

Hope this is what you are looking for.

Nikos

------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

End of grass-user Digest, Vol 90, Issue 4
*****************************************

On Thursday 03 of October 2013 15:47:59 Gregory Penn wrote:

I think that r.blend may accomplish what I need, in terms of compositing
rasters to achieve the effect of partial transparency in a layer. It is not
clear to me how this will work when one or more of the layers that I want
to composite has rgb channels and so is represented by three separate
raster maps (one for each channel) in the mapset.

You can utilise r.composite, in first place, to compose Real- or Pseudo-RGBs.
<http://grass.osgeo.org/grass64/manuals/r.composite.html&gt;\. Try to find an
optimum for your RGBs (friends: r.colors, i.landsat.rgb).

Do I need to create an
image group (i.group) of the three channels and use the group's name as
'first' or 'second' parameter for r.blend?

See above. Note, anyhow, that you can export directly a group that consists
of three maps, say Red, Green and Blue bands of a satellite acquisition as an
example, by using the group's name directly with r.out.gdal. Maybe a useful
tip (?).

The documentation for r.blend seems to indicate that it can only blend two
rasters at a time.

True. So, r.composite first. "r.blend" itself will produce R, G and B which
you need to display with d.rgb, then, I think, use d.out.png. Or, once again,
after "blending", r.composite the final R, G and B maps, then export
(r.out.gdal or d.out.*).

I think it'll work this way. Don't remember currently another way.

Best, Nikos

--%<---%<---

On Thursday 03 of October 2013 11:44:38 Gregory Penn wrote:

>> I am attempting to create maps from the command line, which are
>> composites
>> of several raster and vector layers.

Nikos:

> Working on GRASS 6.x or 7?

>> In order to visualize the data effectively, I need to vary the opacity of
>> the layers. I have found that this is simple to achieve in the wxGUI, but
>> the GUI does not display the underlying module call as it does with many
>> other commands. A little Googling helped me to discover a module called
>> g.pnmcomp, which was apparently used by the old Tcl/Tk GUI for managing
>> layer opacity, but that module appears not to be intended for end users
>> and I suspect that there is an easier and more direct way to achieve my
>> desired results.

> Check r.blend: <http://grass.osgeo.org/grass64/manuals/r.blend.html&gt;,
> <http://grass.osgeo.org/grass70/manuals/r.blend.html&gt;\. The latter
> features a "-c" flag, which does... "Combine resulting R,G,B layers into
> single output map".

>> The process by which I'm creating my maps is essentially this sequence of
>> commands (is there a better approach?):

>> g.region rast=region_raster.tif
>> d.mon start=PNG
>> d.rast map=some_raster.tif
>> d.rast map=another_raster.tif
>> d.vect map=some_vector.shp
>> d.mon stop=PNG

> Ah, this is GRASS6.x then. I think you can still blend maps and then maybe
> use d.out.png to export? See
> <http://grass.osgeo.org/grass64/manuals/d.out.png.html&gt;\.

>> It seems to me that either d.mon or the PNG driver is doing the
>> compositing and so would handle the opacity of the layers, but I can't
>> find any documentation of how to specify values for opacity. This is
>> surprising to me because it seems that what I'm trying to do is such a
>> basic and commonly used operation in creating maps. What am I missing?

> Hope this is what you are looking for.

> Nikos

Gregory Penn wrote:

> I think that r.blend may accomplish what I need, in terms of compositing
> rasters to achieve the effect of partial transparency in a layer. It is
> not clear to me how this will work when one or more of the layers that I
> want to composite has rgb channels and so is represented by three separate
> raster maps (one for each channel) in the mapset.

Nikos Alexandris wrote:

You can utilise r.composite, in first place, to compose Real- or
Pseudo-RGBs. <http://grass.osgeo.org/grass64/manuals/r.composite.html&gt;\. Try
to find an optimum for your RGBs (friends: r.colors, i.landsat.rgb).

Check also this set of instructions:
<http://casoilresource.lawr.ucdavis.edu/drupal/node/159&gt;\.

Nikos