[GRASS-user] translucency and svg output

Hi all

I’m producing maps in svg format using the cairo driver and d.out.file. One thing I’d really like to be able to do is set one or more of the vector layers to be partially translucent. After rummaging through this list, I’m beginning to wonder if its possible at all, since translucency in the guis seems to be handled by g.pnmcomp, but perhaps someone with more experience knows a way to do it.

eg:

d.mon start=x1
d.vect map=road_lines
d.vect map=forest_areas # this is the layer I need translucent
d.out.file -c ~/Desktop/test format=svg
d.mon stop=x1

The only workaround I’ve managed to find so far is to export each layer as an individual svg, then use something like inkscape to rejoin them, setting the translucency/transparency of each layer as I do it. Which is fine for a map with only a few layers, but gets tedious when dealing with maps with dozens of layers.

Any ideas or suggestions?

Regards

Peter Davidson
Postdoctoral Fellow
UCSD Global Public Health

pete davidson wrote:

I'm producing maps in svg format using the cairo driver and d.out.file. One
thing I'd really like to be able to do is set one or more of the vector
layers to be partially translucent. After rummaging through this list, I'm
beginning to wonder if its possible at all, since translucency in the guis
seems to be handled by g.pnmcomp, but perhaps someone with more experience
knows a way to do it.

It isn't. The graphics API doesn't support an alpha component.

Apart from anything else, it can't easily be implemented for
PostScript output, as PostScript doesn't support translucency. Faking
it with patterns is possible, but it starts getting complicated if you
want more than one translucent layer.

The only workaround I've managed to find so far is to export each layer as
an individual svg, then use something like inkscape to rejoin them, setting
the translucency/transparency of each layer as I do it. Which is fine for a
map with only a few layers, but gets tedious when dealing with maps with
dozens of layers.

SVG is XML, so it shouldn't be especially hard to automate the process
using generic XML-processing tools.

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

On Wed, Mar 24, 2010 at 7:42 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

pete davidson wrote:

I’m producing maps in svg format using the cairo driver and d.out.file. One
thing I’d really like to be able to do is set one or more of the vector
layers to be partially translucent. After rummaging through this list, I’m
beginning to wonder if its possible at all, since translucency in the guis
seems to be handled by g.pnmcomp, but perhaps someone with more experience
knows a way to do it.

It isn’t. The graphics API doesn’t support an alpha component.

Apart from anything else, it can’t easily be implemented for
PostScript output, as PostScript doesn’t support translucency. Faking
it with patterns is possible, but it starts getting complicated if you
want more than one translucent layer.

The only workaround I’ve managed to find so far is to export each layer as
an individual svg, then use something like inkscape to rejoin them, setting
the translucency/transparency of each layer as I do it. Which is fine for a
map with only a few layers, but gets tedious when dealing with maps with
dozens of layers.

SVG is XML, so it shouldn’t be especially hard to automate the process
using generic XML-processing tools.

Ohh, I hadn’t thought of editing the svg/xml directly. Thanks for the suggestion, I’ll see what I can achieve from there.

Regards,

Peter

On Wed, Mar 24, 2010 at 7:49 PM, pete davidson <caitifty@gmail.com> wrote:

On Wed, Mar 24, 2010 at 7:42 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

pete davidson wrote:

I’m producing maps in svg format using the cairo driver and d.out.file. One
thing I’d really like to be able to do is set one or more of the vector
layers to be partially translucent. After rummaging through this list, I’m
beginning to wonder if its possible at all, since translucency in the guis
seems to be handled by g.pnmcomp, but perhaps someone with more experience
knows a way to do it.

It isn’t. The graphics API doesn’t support an alpha component.

Apart from anything else, it can’t easily be implemented for
PostScript output, as PostScript doesn’t support translucency. Faking
it with patterns is possible, but it starts getting complicated if you
want more than one translucent layer.

The only workaround I’ve managed to find so far is to export each layer as
an individual svg, then use something like inkscape to rejoin them, setting
the translucency/transparency of each layer as I do it. Which is fine for a
map with only a few layers, but gets tedious when dealing with maps with
dozens of layers.

SVG is XML, so it shouldn’t be especially hard to automate the process
using generic XML-processing tools.

Ohh, I hadn’t thought of editing the svg/xml directly. Thanks for the suggestion, I’ll see what I can achieve from there.

And then we discover that the ‘svg’ produced by cairo using the above script is actually just a png in an svg wrapper… At least for my particular install of Grass. That’s frustrating. Ahh well, back to the drawing board.

Peter

Pete, sorry if I'm off board :
do you absolutely need to generate a /vector/ output ?

Vincent.

Le mercredi 24 mars 2010 à 20:15 -0700, pete davidson a écrit :

On Wed, Mar 24, 2010 at 7:49 PM, pete davidson <caitifty@gmail.com>
wrote:
        
        On Wed, Mar 24, 2010 at 7:42 PM, Glynn Clements
        <glynn@gclements.plus.com> wrote:
                
                pete davidson wrote:
                
                > I'm producing maps in svg format using the cairo
                driver and d.out.file. One
                > thing I'd really like to be able to do is set one or
                more of the vector
                > layers to be partially translucent. After rummaging
                through this list, I'm
                > beginning to wonder if its possible at all, since
                translucency in the guis
                > seems to be handled by g.pnmcomp, but perhaps
                someone with more experience
                > knows a way to do it.
                
                It isn't. The graphics API doesn't support an alpha
                component.
                
                Apart from anything else, it can't easily be
                implemented for
                PostScript output, as PostScript doesn't support
                translucency. Faking
                it with patterns is possible, but it starts getting
                complicated if you
                want more than one translucent layer.
                
                > The only workaround I've managed to find so far is
                to export each layer as
                > an individual svg, then use something like inkscape
                to rejoin them, setting
                > the translucency/transparency of each layer as I do
                it. Which is fine for a
                > map with only a few layers, but gets tedious when
                dealing with maps with
                > dozens of layers.
                
                SVG is XML, so it shouldn't be especially hard to
                automate the process
                using generic XML-processing tools.
        
        Ohh, I hadn't thought of editing the svg/xml directly. Thanks
        for the suggestion, I'll see what I can achieve from there.
        
And then we discover that the 'svg' produced by cairo using the above
script is actually just a png in an svg wrapper.. At least for my
particular install of Grass. That's frustrating. Ahh well, back to
the drawing board.

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

Hello,

Just installed grass 7.0 using the latest snapshot binary march 20 (grass7.0.svn-i686-pc-linux-gnu-20_03_2010) and ubuntu 9.10. I type in grass70 in the shell and nothing happens. No error but also no gui. I try some gui commands and it says command not found. Nothing really works but the program seems to activate.

I use grass 6.4 often but am at a loss as to what the problem is.

Thanks,

Matthew

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


The New Busy is not the old busy. Search, chat and e-mail from your inbox. Get started.

Hi Matthew,
just an idea : did you check if grass70 exists in your path and if so,
is it executable (you can type sth like ls -l /usr/bin/grass* in a term)

Yours,
Vincent.

Le jeudi 25 mars 2010 à 12:24 +0000, Matthew Mulbrandon a écrit :

Hello,

Just installed grass 7.0 using the latest snapshot binary march 20
(grass7.0.svn-i686-pc-linux-gnu-20_03_2010) and ubuntu 9.10. I type in
grass70 in the shell and nothing happens. No error but also no gui. I
try some gui commands and it says command not found. Nothing really
works but the program seems to activate.

I use grass 6.4 often but am at a loss as to what the problem is.

Thanks,

Matthew

> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

______________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your
inbox. Get started.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

pete davidson wrote:

And then we discover that the 'svg' produced by cairo using the above script
is actually just a png in an svg wrapper.. At least for my particular
install of Grass. That's frustrating. Ahh well, back to the drawing board.

Cairo falls back to rasterisation as soon as it encounters anything
which it might not be able to implement using vector operations.

For me, a simple "d.vect fields" produces "real" (vector) SVG output.
You might want to experiment with the command options (and the
environment variables used by the cairo driver) to see if a specific
feature is triggering rasterisation.

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

Ignoring the aim of Pete's graphical outputs, perhaps my advice will be
trivial, but quite often people want to keep vectorial formats very
"far" in the output process eventhough they don't have special
post-editing needs. I was of those till I understood raster formats
advantages for pre-press, among which:
* kind of stability between platforms/softwares (no surprise when
interpreting the format, as it often happens e.g. with poor quality
postscript interpreters);
* very acceptable accuracy (beyond 300 dpi for a color output is useless
regarding common printers technology);
* lightness (if you ever tried to generate a complex A3 pdf doc with
multiple translucent layers above a raster background, you might know
what I mean...)

It is quite easy with Grass to write a script that:
* outputs a ps file for each layer you need to overlay (may they be
numerous, you have control on image size and map extent),
* then performs the composition with a command line image editor (image
magick can interprete postscript if you have ghostscript installed on
your system) that does deal with blending options.

I can provide examples for those interested...

Vincent

Le jeudi 25 mars 2010 à 15:12 +0000, Glynn Clements a écrit :

pete davidson wrote:

> And then we discover that the 'svg' produced by cairo using the above script
> is actually just a png in an svg wrapper.. At least for my particular
> install of Grass. That's frustrating. Ahh well, back to the drawing board.

Cairo falls back to rasterisation as soon as it encounters anything
which it might not be able to implement using vector operations.

For me, a simple "d.vect fields" produces "real" (vector) SVG output.
You might want to experiment with the command options (and the
environment variables used by the cairo driver) to see if a specific
feature is triggering rasterisation.

Thanks to all for these suggestions and comments.

I will look at the options suggested by Andreas, and follow Glynn’s comment to explore why Cairo dropped to rasterization - it’s good to know that that’s why I got raster output, rather than wrapping a raster being all that Cairo does!

To answer Hamish, no, I was exporting each individual layer using d.vect and d.out.file. Your question gives me the idea I should try using v.out.svg for individual layers to help work out why Cairo dropped to raster output and/or to produce individual layers to stitch together later if necessary.

Re Vincent’s comment that holding vector format to ‘the very end’, unfortunately what I’m doing isn’t for single-use - I’m producing maps that will be used by several end users for uses ranging from conference posters to individual papers, so I can’t predict final image sizes in advance (and I’m not going to be the only end-user). Hence my desire to stick to a vector format in the hopes that they’ll at least scale cleanly. Although if Vincent is willing to share an example script that uses imagemagik to compose ps layers I’d be delighted to see it.

Thanks again to all for sharing your thoughts & expertise.

Peter

pete davidson wrote:

To answer Hamish, no, I was exporting each individual layer using d.vect and
d.out.file.

You might also want to try using the cairo driver directly, rather
than using d.out.file. E.g.:

  export GRASS_CAIROFILE=out.svg
  d.mon start=cairo
  d.vect ...
  d.vect ...
  d.mon stop=cairo

Your question gives me the idea I should try using v.out.svg
for individual layers to help work out why Cairo dropped to raster output
and/or to produce individual layers to stitch together later if necessary.

v.out.svg doesn't use cairo, and will never rasterise anything.

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

Le jeudi 25 mars 2010 à 13:59 -0700, pete davidson a écrit :

Although if Vincent is willing to share an example script that uses
imagemagik to compose ps layers I'd be delighted to see it.

Lacking time for a complete set of examples with a geodataset, this
archive :
http://www.lesfavrets.fr/telec/psmap.tar.gz
provides an example shell script that fixes settings for a map
composition (pagesize, borders), runs 4 instances of ps.map on a given
mapset conforming these settings, then outputs a jpg composition of the
4 ps layers.

ps.map is really powerfull in the context of maps serial production.
Eventhough the module is not user friendly, its adaptability suits
perfectly automation needs !

Bye,
Vincent

Matthew Mulbrandon a écrit :

> Just installed grass 7.0 using the latest snapshot binary march 20
> (grass7.0.svn-i686-pc-linux-gnu-20_03_2010) and ubuntu 9.10.

How did you install grass70?

I type in

> grass70 in the shell and nothing happens. No error but also no gui. I
> try some gui commands and it says command not found. Nothing really
> works but the program seems to activate.
> I use grass 6.4 often but am at a loss as to what the problem is.

On Thu, 2010-03-25 at 14:31 +0100, Vincent Bain wrote:

Hi Matthew, just an idea : did you check if grass70 exists in your path and if so,
is it executable (you can type sth like ls -l /usr/bin/grass* in a term)

Also:

#whereis
whereis grass70

# more options
sudo updatedb # update db for "locate"

# use locate
locate grass70

Nikos

Ok this is the error when I start the latest grass7 in ubuntu 9.10 (from below)
matthew@matthew-laptop:~$ grass70

WELCOME TO GRASS Version 7.0.svn 2010

  1. Have at your side all available GRASS tutorials

  2. When working on your location, the following materials
    are extremely useful:

  • A topo map of your area
  • Current catalog of available computer maps
  1. Check the GRASS webpages for feedback mailinglists and more:
    http://www.grass-gis.org
    http://grass.osgeo.org

Hit RETURN to continue

Starting GRASS …
Traceback (most recent call last):
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 825, in
GRASSStartUp = StartUp(0)
File “/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 7978, in init
self._BootstrapApp()
File “/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 7552, in _BootstrapApp
return core.PyApp__BootstrapApp(args, **kwargs)
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 796, in OnInit
StartUp = GRASSStartup()
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 163, in init
self._set_properties()
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 210, in _set_properties
self.OnSetDatabase(None)
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 655, in OnSetDatabase
self.UpdateLocations(self.gisdbase)
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gis_set.py”, line 533, in UpdateLocations
self.listOfLocations = utils.GetListOfLocations(dbase)
File “/usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/wxpython/gui_modules/utils.py”, line 557, in GetListOfLocations
for location in glob.glob(os.path.join(dbase, "
")):
File “/usr/lib/python2.6/glob.py”, line 16, in glob
return list(iglob(pathname))
File “/usr/lib/python2.6/glob.py”, line 43, in iglob
yield os.path.join(dirname, name)
File “/usr/lib/python2.6/posixpath.py”, line 70, in join
path += ‘/’ + b
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd0 in position 2: ordinal not in range(128)
Error in GUI startup. If necessary, please
report this error to the GRASS developers.
Switching to text mode now.

Hit RETURN to continue…

mkdir: cannot create directory `/tmp/grass7-matthew-11707’: File exists
Cannot create temporary directory! Exiting.
Cleaning up temporary files …
access: No such file or directory
ERROR: LOCATION << /home/matthew/ >> not available
Starting GRASS …
/home/matthew///.gislock: No such file or directory
ERROR: /usr/local/grass7.0.svn-i686-pc-linux-gnu-20_03_2010/etc/lock:
Unable to properly access /home/matthew///.gislock
Please notify system personel.
matthew@matthew-laptop:~$ ^C
matthew@matthew-laptop:~$

Again any help would be great as I do not know were to start.

Thanks,

Matthew

Subject: Re: [GRASS-user] grass 7 and ubuntu start up
From: nikos.alexandris@felis.uni-freiburg.de
To: bain@toraval.fr
CC: mulbran@hotmail.com; grass-user@lists.osgeo.org
Date: Mon, 5 Apr 2010 23:41:42 +0200

Matthew Mulbrandon a écrit :

Just installed grass 7.0 using the latest snapshot binary march 20
(grass7.0.svn-i686-pc-linux-gnu-20_03_2010) and ubuntu 9.10.

How did you install grass70?

I type in

grass70 in the shell and nothing happens. No error but also no gui. I
try some gui commands and it says command not found. Nothing really
works but the program seems to activate.
I use grass 6.4 often but am at a loss as to what the problem is.

On Thu, 2010-03-25 at 14:31 +0100, Vincent Bain wrote:

Hi Matthew, just an idea : did you check if grass70 exists in your path and if so,
is it executable (you can type sth like ls -l /usr/bin/grass* in a term)

Also:

#whereis
whereis grass70

more options

sudo updatedb # update db for “locate”

use locate

locate grass70

Nikos


The New Busy is not the old busy. Search, chat and e-mail from your inbox. Get started.