[GRASS-dev] [GRASS GIS] #3033: Cairo and PS drivers display only one raster or vector for SVG and PS

GRASS GIS trac at osgeo.org
Tue May 17 15:24:38 PDT 2016

#3033: Cairo and PS drivers display only one raster or vector for SVG and PS
  Reporter:  wenzeslaus  |      Owner:  grass-dev@…
      Type:  defect      |     Status:  new
  Priority:  major       |  Milestone:  7.2.0
 Component:  Display     |    Version:  svn-trunk
Resolution:              |   Keywords:  d.mon, cairo, ps, SVG, vector
       CPU:              |  graphics
  Unspecified            |   Platform:  Unspecified

Comment (by wenzeslaus):

 Replying to [comment:1 glynn]:
 > It isn't possible to initialise a surface from an existing SVG file so
 that subsequent drawing operations will be appended to the document
 structure, and you can't simply concatenate the files.

 This is serious limitation. Is there a way to change the rendering to not
 have this problem.

 > You need to generate multiple output files then combine them with
 external tools.

 I was able to use HTML:

 g.region rast=elevation
 d.mon cairo output=elevation.svg
 d.rast elevation
 d.mon stop=cairo
 d.mon cairo output=streams.svg
 d.vect streams color=blue
 d.mon stop=cairo
 d.mon cairo output=roadsmajor.svg
 d.vect roadsmajor
 d.mon stop=cairo

 object {
     position: absolute;
     top: 0;
     left: 0;
 # also svg element can be used
 <object type="image/svg+xml" data="elevation.svg"></object>
 <object type="image/svg+xml" data="streams.svg"></object>
 <object type="image/svg+xml" data="roadsmajor.svg"></object>

 Unfortunately, this is not a sufficient workaround if you need to modify
 the file.

 Combining manually in Inkscape was not possible; I was not able to align
 the layers. Command line Inkscape doesn't read multiple files. !ImageMagic
 creates a raster.

 > To combine the output from multiple commands into a single file, all
 commands but the first should have GRASS_RENDER_PS_HEADER=FALSE, while all
 commands but the last should have GRASS_RENDER_PS_TRAILER=FALSE.

 Thanks for the tip, this worked:

 g.region rast=elevation
 d.mon ps output=all.ps
 d.rast elevation
 d.vect streams color=blue
 d.vect roadsmajor
 # export here worked as well
 d.mon stop=ps

 I followed with

 pdf2svg all.pdf all.svg
 ps2pdf all.ps all.pdf

 to get SVG. But it seems that PS driver is not as powerful as Cairo and
 same things are lost during the subsequent conversions, page size was
 wrong as well.

 Unfortunately, this doesn't seem to be applicable for GUI which would be
 likely used when one wants to edit the file afterwards.

Ticket URL: <https://trac.osgeo.org/grass/ticket/3033#comment:2>
GRASS GIS <https://grass.osgeo.org>

More information about the grass-dev mailing list