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

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?

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

On Thursday 03 of October 2013 14:21:03 Gregory Penn wrote:

Nikos,

Hi Gregory!

Better on-list, the experts will jump-in, others will benefit as well from the
discussion.

Thanks for your help. I think that r.blend might be the module that I needed
to find. Would you mind answering an additional question? You were able to
tell from the sequence of commands that I'm using that I'm using GRASS 6.x
and not GRASS 7, either because what I'm doing won't work in GRASS 7 or
because there's a better way.

I simply guessed that you use "d.mon start=/stop=" in GRASS 6.x. Note, there
are no X "monitors" any more in G7, only wx-Monitors! This was (is) quite
some groundbreaking change in GRASS GIS' own ecosystem. Many of the d.*
scripts/modules wont work anymore. And, (my!) truth told, there are some of
them which are Fantastic.

Having looked at the documentation, I think that many of the new features in
GRASS 7 will be very helpful to me and I'd like to make the transition.

The transition isn't that hard per se I think. But you might miss some of the
d.mon, given you work a lot in the command line, related goodies (such as
splitting in multiple frames for example). Then again, you will find new
goodies such as g.gui.mapswipe :slight_smile:

Could you explain (or direct me to documentation) how I should accomplish
the same thing in GRASS 7?

I think in this very example nothing changes. It is the exact same sequence.
Just another note, you do know/use the "-o (overlay)" flag in grass6.x, right?

What I'm trying to do is pretty simple for now: create an image file that is
a composite of several raster and vector layers.

See also my previous reply (to the list).

Cheers,
Gregory

Best of success, Nikos

p.s. I just realized that this response is going to your email address and
not to the list. Please let me know if I should repost this to the list, in
which case you can ignore this message and respond there.

pps- I took the liberty to cc- the list, hope you wont mind :slight_smile:

[rest deleted]