[GRASS-user] Adjust opacity in command line

Hello,

I have been trying to find a way to adjust the opacity (or
transparency, to throw another key word in there) of raster and vector
layers using the command line. This is possible in the wxPython GUI,
but I have a large number of maps to produce, and would like to script
it. So if anyone knows if this is possible with the standard d.*
commands, ps.map, or something else I don't know about - thanks in
advance!

Andy Wickert

Andy Wickert wrote:

I have been trying to find a way to adjust the opacity (or
transparency, to throw another key word in there) of raster and vector
layers using the command line. This is possible in the wxPython GUI,
but I have a large number of maps to produce, and would like to script
it. So if anyone knows if this is possible with the standard d.*
commands, ps.map, or something else I don't know about - thanks in
advance!

It isn't possible to directly generate images with partial opacity.
wxGUI (via g.pnmcomp) uses the opacity values when compositing the
layers to form the displayed image.

You'll need to use general-purpose image-processing tools such as
ImageMagick, netpbm or Python+PIL. Blending between an empty
(fully-transparent) image and the source image is probably the easiest
approach.

--
Glynn Clements <glynn@gclements.plus.com>

On Tue, Aug 28, 2012 at 4:19 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Andy Wickert wrote:

I have been trying to find a way to adjust the opacity (or
transparency, to throw another key word in there) of raster and vector
layers using the command line. This is possible in the wxPython GUI,
but I have a large number of maps to produce, and would like to script
it. So if anyone knows if this is possible with the standard d.*
commands, ps.map, or something else I don't know about - thanks in
advance!

It isn't possible to directly generate images with partial opacity.
wxGUI (via g.pnmcomp) uses the opacity values when compositing the
layers to form the displayed image.

You'll need to use general-purpose image-processing tools such as
ImageMagick, netpbm or Python+PIL. Blending between an empty
(fully-transparent) image and the source image is probably the easiest
approach.

Perhaps "r.blend" could be of interest to some extent.

Markus

Andy wrote:

I have been trying to find a way to adjust the opacity (or
transparency, to throw another key word in there)
of raster and vector layers using the command line.

for two rasters you can use the d.shadedmap module for a similar effect.
It's just a wrapper around a trick with the d.his module.

examples:
  http://grass.osgeo.org/grass63/screenshots/images/fourmaps.jpg
  http://grass.osgeo.org/grass63/screenshots/images/spearfish_catchements.png

(see raster screenshots on the homepage for scripts that made those)

It's a bit limited in what it can be used for, but for the case of a
categorical area map (maybe 'v.to.rast type=area') over a shaded relief
DEM it works quite nicely.

Hamish

Thanks for the answers! (And sorry for the delayed reply - been
traveling). I went for the manual (ImageMagick) option, and that
worked well.
Andy

On Wed, Aug 29, 2012 at 5:37 AM, Hamish <hamish_b@yahoo.com> wrote:

Andy wrote:

I have been trying to find a way to adjust the opacity (or
transparency, to throw another key word in there)
of raster and vector layers using the command line.

for two rasters you can use the d.shadedmap module for a similar effect.
It's just a wrapper around a trick with the d.his module.

examples:
  http://grass.osgeo.org/grass63/screenshots/images/fourmaps.jpg
  http://grass.osgeo.org/grass63/screenshots/images/spearfish_catchements.png

(see raster screenshots on the homepage for scripts that made those)

It's a bit limited in what it can be used for, but for the case of a
categorical area map (maybe 'v.to.rast type=area') over a shaded relief
DEM it works quite nicely.

Hamish