[GRASS-user] editing grass postscript maps

Tyler Smith tyler.smith at mail.mcgill.ca
Wed May 16 17:14:11 EDT 2007

On Wed, May 16, 2007 at 05:49:28PM +1200, Hamish wrote:
> a2ps --margin[=NUM]
>        define an interior margin of size NUM

a2ps was a bust for me. My individual maps are 3"x2" landscape-layout,
and I want them printed on a single letter-size page in portrait
layout. I couldn't get anything close to that with a2ps.

> But you will only lose resoution resampling to
> raster, so try hard for a PSutils solution first.

Ok, my solution to this problem, preserved here for posterity, is as

Generate the maps. Script pasted below.

Combine the maps:

psmerge -omerged.ps *.ps

Arrange the maps on a single sheet:

psnup -s1 -m0.01in -b0 -w5.5in -h7in -W2.73in -H1.75in -8 \
       merged.ps psnupped.ps

The -s1 flag was critical - otherwise psnup kept trying to rescale the
individual images, which added lots of ugly whitespace around them.

Before I added the -m flag no bounding box was generated, and latex
couldn't process the file.

The output of psnup was fine but for one thing. The bounding box was
listed as if there was only one 3x2 map, not a 5.5x7
composite. Inserting this into Latex meant that all placement commands
operated as if only the bottom left map was there, resulting in

Opening up the .ps file I found that the bounding box information was
on line three, and despite knowing nothing of postscript I guessed
correctly what was necessary:

tyler:geography-> head -3 psnupped.ps 
%%Pages: 1 0
%%BoundingBox: 0 0 196 126

tyler:geography-> cat psnup.head
%%Pages: 1 0
%%BoundingBox: 0 0 400 510
                   ^^^ ^^^ corrected values

Of course, the output of psnup was too big to be opened in emacs, so I
had to cut the head off it, cut the tail off it, modify the head, and
then put them all back together:

tyler:geography-> tail -n +4 psnupped.ps > psnuptail.ps

<edit psnup.head in an editor>

tyler:geography-> cat psnup.head psnuptail.ps > psnupbb.ps

I found out the hard way that doing this in one step was a recipe for

tyler:geography-> cat psnup.head $(tail -n +4 psnupped.ps) > psnupbb.ps

After 30 or 40 minutes of constant swapping I killed that (with some
difficulty) and did it as three separate steps, which completed in a
few minutes.

The actual size of the files became an issue. Each of the eight maps
was 100MB, and the merged file was ca. 500MB. Half-way through the day
I ran into the problem that my 27GB home partition was stuffed full,
with more than 5GB taken up by failed postscript experiments. Much of
the rest of the space is taken by larger raster datasets - if only I'd
known GIS was going to be like this I'd have bought a bigger harddrive!

Anyways, I've got what I need, and it only took my twice as long as I
thought it should take.

Thanks for your suggestions, and let me know if you can think of any
other ways to improve on my very ugly solution.



Here's my ps.map script, to be complete:



for map_name in aest_90 bush_90 carol_90 comp_90 \
    hirs_90 roan_90 swan_90 vir_90; 


  lab_let=$(echo -n $(printf "\\x$(echo $lab_num)"))

  echo "paper
  top 0 inches
  bottom 0 inches
  right 0 inches
  left 0 inches
  width 2.73 inches
  height 1.75 inches

  text -63 27 $lab_let
  fontsize 12
  font Helvetica-Bold

  vlines na_bound
    type boundary
    color black
    width 0.5

  grid 15 
    cross 0.5
    numbers 1
    width 1
    fontsize 6

  raster $map_name

  end" |   ps.map output=${map_name}.ps ;

  echo $((lab_num++)) > /dev/null ;


More information about the grass-user mailing list