[GRASS-user] editing grass postscript maps

Hi,

I'm working on getting my GRASS maps ready for publication. I've
worked my way through ps.map successfully, with eight nice maps. I'd
like to make a single plate with all eight maps. I usually do my
graphics editing with Gimp or Inkscape. However, in Gimp the maps are
very grainy, which I imagine is a consequence of their being converted
from ps to bitmap format. When I try to open them in Inkscape the
vectors come out nice and clear, but the raster layers are completely
absent. I've tried opening them, importing them, and converting them
to svg manually using pstoedit, all with pretty much the same result.

My questions are:

Is there a way to make a multi-map plate directly in GRASS, or

What is the recommended way to manipulate the ps files outside of
GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
access to lots of graphics programs, if anyone can recommend something
better than what I've tried.

Thanks,

Tyler

--
Who is your computer working for?

http://www.defectivebydesign.org/faq

how about concat-ing the figures into a single PS file, then converting to a
PDF with 8 pages per sheet ?

I know that many KDE apps can do this in the print options -- which probably
just invoke gs with some magic incantations...

cheers,

dylan

On Tuesday 15 May 2007 12:53, Tyler Smith wrote:

Hi,

I'm working on getting my GRASS maps ready for publication. I've
worked my way through ps.map successfully, with eight nice maps. I'd
like to make a single plate with all eight maps. I usually do my
graphics editing with Gimp or Inkscape. However, in Gimp the maps are
very grainy, which I imagine is a consequence of their being converted
from ps to bitmap format. When I try to open them in Inkscape the
vectors come out nice and clear, but the raster layers are completely
absent. I've tried opening them, importing them, and converting them
to svg manually using pstoedit, all with pretty much the same result.

My questions are:

Is there a way to make a multi-map plate directly in GRASS, or

What is the recommended way to manipulate the ps files outside of
GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
access to lots of graphics programs, if anyone can recommend something
better than what I've tried.

Thanks,

Tyler

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

On Tue, 2007-05-15 at 16:53 -0300, Tyler Smith wrote:

What is the recommended way to manipulate the ps files outside of
GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
access to lots of graphics programs, if anyone can recommend something
better than what I've tried.

You could try a combination of 'psmerge' and 'psnup' programs, both from
the package 'psutils'. Both work from the command line.

Or if you have produced eps-files, perhaps epstopdf -> pdfjoin -> pdfnup
-> pdftops.

Harri K.

On Tue, 15 May 2007, Dylan Beaudette wrote:

how about concat-ing the figures into a single PS file, then converting to a
PDF with 8 pages per sheet ?

psutils (http://www.tardis.ed.ac.uk/~ajcd/psutils/index.html), in particular the psnup command, can do this to PostScript without any conversion - I've used it sucessfully many times, although the last was quite a few years ago now. Perhaps it is installed by default on Debian?

But I was assuming there'd be a need to put extra captions and stuff under the maps and re-arrange them on the page, which psnup won't do. I'd say definitely the Inkscape approach is the one to go with from this point of view; perhaps it's worth investigating in more depth what the problem with it is (e.g. look at the raw postscript text where the image is included or something - try it with images from the new GRASS postscript display driver and compare results or something) before spending a lot of time looking at alternative solutions?

Paul

I know that many KDE apps can do this in the print options -- which probably
just invoke gs with some magic incantations...

cheers,

dylan

On Tuesday 15 May 2007 12:53, Tyler Smith wrote:

Hi,

I'm working on getting my GRASS maps ready for publication. I've
worked my way through ps.map successfully, with eight nice maps. I'd
like to make a single plate with all eight maps. I usually do my
graphics editing with Gimp or Inkscape. However, in Gimp the maps are
very grainy, which I imagine is a consequence of their being converted
from ps to bitmap format. When I try to open them in Inkscape the
vectors come out nice and clear, but the raster layers are completely
absent. I've tried opening them, importing them, and converting them
to svg manually using pstoedit, all with pretty much the same result.

My questions are:

Is there a way to make a multi-map plate directly in GRASS, or

What is the recommended way to manipulate the ps files outside of
GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
access to lots of graphics programs, if anyone can recommend something
better than what I've tried.

Thanks,

Tyler

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

latex ???

On Tuesday 15 May 2007 13:29, Paul Kelly wrote:

On Tue, 15 May 2007, Dylan Beaudette wrote:
> how about concat-ing the figures into a single PS file, then converting
> to a PDF with 8 pages per sheet ?

psutils (http://www.tardis.ed.ac.uk/~ajcd/psutils/index.html), in
particular the psnup command, can do this to PostScript without any
conversion - I've used it sucessfully many times, although the last was
quite a few years ago now. Perhaps it is installed by default on Debian?

But I was assuming there'd be a need to put extra captions and stuff under
the maps and re-arrange them on the page, which psnup won't do. I'd say
definitely the Inkscape approach is the one to go with from this point of
view; perhaps it's worth investigating in more depth what the problem with
it is (e.g. look at the raw postscript text where the image is included or
something - try it with images from the new GRASS postscript display
driver and compare results or something) before spending a lot of time
looking at alternative solutions?

Paul

> I know that many KDE apps can do this in the print options -- which
> probably just invoke gs with some magic incantations...
>
> cheers,
>
> dylan
>
> On Tuesday 15 May 2007 12:53, Tyler Smith wrote:
>> Hi,
>>
>> I'm working on getting my GRASS maps ready for publication. I've
>> worked my way through ps.map successfully, with eight nice maps. I'd
>> like to make a single plate with all eight maps. I usually do my
>> graphics editing with Gimp or Inkscape. However, in Gimp the maps are
>> very grainy, which I imagine is a consequence of their being converted
>> from ps to bitmap format. When I try to open them in Inkscape the
>> vectors come out nice and clear, but the raster layers are completely
>> absent. I've tried opening them, importing them, and converting them
>> to svg manually using pstoedit, all with pretty much the same result.
>>
>> My questions are:
>>
>> Is there a way to make a multi-map plate directly in GRASS, or
>>
>> What is the recommended way to manipulate the ps files outside of
>> GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
>> access to lots of graphics programs, if anyone can recommend something
>> better than what I've tried.
>>
>> Thanks,
>>
>> Tyler
>
> --
> Dylan Beaudette
> Soils and Biogeochemistry Graduate Group
> University of California at Davis
> 530.754.7341
>
> _______________________________________________
> grassuser mailing list
> grassuser@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Tyler wrote:

> I'm working on getting my GRASS maps ready for publication. I've
> worked my way through ps.map successfully, with eight nice maps. I'd
> like to make a single plate with all eight maps.

..

> Is there a way to make a multi-map plate directly in GRASS, or

Not with ps.map. The new 'd.out.file format=ps' + d.frame might work.

> What is the recommended way to manipulate the ps files outside of
> GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
> access to lots of graphics programs, if anyone can recommend
> something better than what I've tried.

Dylan wrote:

how about concat-ing the figures into a single PS file, then
converting to a PDF with 8 pages per sheet ?

a2ps --landscape --columns=4 --rows=2 -o outfile.ps [FILE(s)]

or maybe just

a2ps -8 -o outfile.ps [FILE(s)]
ps2pdf13 outfile.ps

I think you can pass it multiple input file without having to use cat
first.

Hamish

On Tue, May 15, 2007 at 09:29:42PM +0100, Paul Kelly wrote:

On Tue, 15 May 2007, Dylan Beaudette wrote:

>how about concat-ing the figures into a single PS file, then converting to
>a
>PDF with 8 pages per sheet ?

psutils (http://www.tardis.ed.ac.uk/~ajcd/psutils/index.html), in
particular the psnup command, can do this to PostScript without any
conversion - I've used it sucessfully many times, although the last was
quite a few years ago now. Perhaps it is installed by default on Debian?

psnup is ok, but there is no direct way to control the spacing between
the original ps files, at least not that I can find. I've not got a
nice 2-column layout, but with big gaps betwen the columns and rows of
images, which will be a deal-breaker trying to get this published. The
actual code I used was:

psmerge -omerge.ps *.ps
psnup -m1in -w8.5in -h11in -W3in -H2in -8 merge.ps psnupped.ps

But I was assuming there'd be a need to put extra captions and stuff under
the maps and re-arrange them on the page, which psnup won't do.

All I need is a letter in the corner of each plot, which ps.map will
do without much bother. The captions will be done in LaTeX.

I'd say
definitely the Inkscape approach is the one to go with from this point of
view; perhaps it's worth investigating in more depth what the problem with
it is (e.g. look at the raw postscript text where the image is included or
something - try it with images from the new GRASS postscript display
driver and compare results or something) before spending a lot of time
looking at alternative solutions?

um, yeah. I looked at the raw postscript code and confirmed that I do
in fact have no knowledge of even the most basic structure of
postscript code.

I have just now figured out what I was doing wrong with the Gimp. I
was opening the .eps files I had generated with ps.map at 300dpi, but
the base layer was only 100dpi, so the resolution was 100dpi in the
final image. Now that I know that, it looks like I should be able to
get clear, if very large, images out of the gimp after all. So if I
can't get inkscape to display the raster layer in lovely colour, at
least I can get a usable image out of that, at least for my thesis.

Thanks,

Tyler

Paul

>
>I know that many KDE apps can do this in the print options -- which
>probably
>just invoke gs with some magic incantations...
>
>cheers,
>
>dylan
>
>On Tuesday 15 May 2007 12:53, Tyler Smith wrote:
>>Hi,
>>
>>I'm working on getting my GRASS maps ready for publication. I've
>>worked my way through ps.map successfully, with eight nice maps. I'd
>>like to make a single plate with all eight maps. I usually do my
>>graphics editing with Gimp or Inkscape. However, in Gimp the maps are
>>very grainy, which I imagine is a consequence of their being converted
>>from ps to bitmap format. When I try to open them in Inkscape the
>>vectors come out nice and clear, but the raster layers are completely
>>absent. I've tried opening them, importing them, and converting them
>>to svg manually using pstoedit, all with pretty much the same result.
>>
>>My questions are:
>>
>>Is there a way to make a multi-map plate directly in GRASS, or
>>
>>What is the recommended way to manipulate the ps files outside of
>>GRASS to achieve this? I'm using Debian GNU/Linux, so have ready
>>access to lots of graphics programs, if anyone can recommend something
>>better than what I've tried.
>>
>>Thanks,
>>
>>Tyler
>
>--
>Dylan Beaudette
>Soils and Biogeochemistry Graduate Group
>University of California at Davis
>530.754.7341
>
>_______________________________________________
>grassuser mailing list
>grassuser@grass.itc.it
>http://grass.itc.it/mailman/listinfo/grassuser
>

--
Friends don't let friends send Word documents

http://www.nothingisreal.com/dfki/no-word

Paul:

> psutils (http://www.tardis.ed.ac.uk/~ajcd/psutils/index.html), in
> particular the psnup command, can do this to PostScript without any
> conversion - I've used it sucessfully many times, although the last
> was quite a few years ago now. Perhaps it is installed by default
> on Debian?

Tyler:

psnup is ok, but there is no direct way to control the spacing between
the original ps files, at least not that I can find.

a2ps --margin[=NUM]
       define an interior margin of size NUM

> But I was assuming there'd be a need to put extra captions and stuff
> under the maps and re-arrange them on the page, which psnup won't
> do.

All I need is a letter in the corner of each plot, which ps.map will
do without much bother. The captions will be done in LaTeX.

I've just put up a new example in the d.out.file help page demonstrating
this for the new PS driver.

I have just now figured out what I was doing wrong with the Gimp. I
was opening the .eps files I had generated with ps.map at 300dpi, but
the base layer was only 100dpi, so the resolution was 100dpi in the
final image. Now that I know that, it looks like I should be able to
get clear, if very large, images out of the gimp after all. So if I
can't get inkscape to display the raster layer in lovely colour, at
least I can get a usable image out of that, at least for my thesis.

one trick how to do that nicely: open it at 1200dpi or so, then rescale
down using the rescale tool (Shift-T) + Cubic interpolation. May or may
not give you better results than going to the target size directly from
the File->Open dialog. But you will only lose resoution resampling to
raster, so try hard for a PSutils solution first.

Hamish

On 15/05/07 21:53, Tyler Smith wrote:

Hi,

I'm working on getting my GRASS maps ready for publication. I've
worked my way through ps.map successfully, with eight nice maps. I'd
like to make a single plate with all eight maps. I usually do my
graphics editing with Gimp or Inkscape. However, in Gimp the maps are
very grainy, which I imagine is a consequence of their being converted
from ps to bitmap format. When I try to open them in Inkscape the
vectors come out nice and clear, but the raster layers are completely
absent. I've tried opening them, importing them, and converting them
to svg manually using pstoedit, all with pretty much the same result.

You've received many other valid recommendations, but as ultimate solution you could also export vector and raster layers separately and the put them back together in inkscape.

Moritz

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

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

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
%!PS-Adobe-3.0
%%Pages: 1 0
%%BoundingBox: 0 0 196 126

tyler:geography-> cat psnup.head
%!PS-Adobe-3.0
%%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
disaster:

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.

Cheers,

Tyler

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

#!/bin/bash

lab_num=41

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

  do

  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
  end

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

  vlines na_bound
    type boundary
    color black
    width 0.5
  end

  grid 15
    cross 0.5
    numbers 1
    width 1
    fontsize 6
  end

  raster $map_name

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

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

  done

On Wednesday 16 May 2007 14:14, Tyler Smith wrote:

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

It is possible to multiple-map composition in GMT, you could give that a try
next time... ?

cheers,

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Tyler Smith wrote:

The actual size of the files became an issue. Each of the eight maps
was 100MB,

Ouch.

Next time, you might want to use "g.region res=" to reduce the size of
the raster data. 100MB is ~16 million pixels @ 6 bytes/pixel (RRGGBB).

Looking at the "paper" command:

  width 2.73 inches
  height 1.75 inches

2.73 * 1.75 = 4.7775 sq.in.
100e6 / 6 = 16666667 pixels
16666667 / 4.7775 = 3488575 pixels/sq.in.
sqrt(3488575) = 1868 pixels/in

Even if the printer does 2400 DPI, the halftone resolution is going to
be a fraction of that, so you could reduce the resolution
substantially without seeing any noticable difference.

I doubt that there's much point in going above 300 DPI (around 1/6th
of what you appear to have) for a raster; 2.73" * 1.75" @ 300 DPI
would be 819 * 525.

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

On Thu, May 17, 2007 at 01:13:47AM +0100, Glynn Clements wrote:

Next time, you might want to use "g.region res=" to reduce the size of
the raster data. 100MB is ~16 million pixels @ 6 bytes/pixel (RRGGBB).

Looking at the "paper" command:

  width 2.73 inches
  height 1.75 inches

2.73 * 1.75 = 4.7775 sq.in.
100e6 / 6 = 16666667 pixels
16666667 / 4.7775 = 3488575 pixels/sq.in.
sqrt(3488575) = 1868 pixels/in

I doubt that there's much point in going above 300 DPI (around 1/6th
of what you appear to have) for a raster; 2.73" * 1.75" @ 300 DPI
would be 819 * 525.

So, if g.region -p tells me:

nsres: 0:00:30.0024
ewres: 0:00:30.0024

To reduce the resolution by 1/6 I would do:

g.region res=0:03:00.0000

Is that right?

I'll give it a try...

Done!

My completed figure is now 16MB instead of 500MB, and it looks fine!
Wish I'd known about g.region res before -- next time it will be
much easier, and will take a lot less time and disk space.

Thanks,

Tyler

--
Tired of spyware? Try Firefox:

www.firefox.com