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

Nikos Alexandris nik at nikosalexandris.net
Thu Oct 3 17:19:59 PDT 2013


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>. 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>,
> > <http://grass.osgeo.org/grass70/manuals/r.blend.html>.  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>.


> >> 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


More information about the grass-user mailing list