[GRASS-user] creating map series purely on ps.map

Hamish hamish_b at yahoo.com
Thu Aug 20 06:07:39 EDT 2009


maning wrote:
> Basically my workflow for creating paper maps is create the
> main map in ps.map.  Export the ps output to pdf or png in a
> graphics software (scribus or illustrator).  Edit all map elements
> legend, anotations, etc.
> 
> What I want is to be bale to create the map purely within
> grass and ps.map module.

sure, it's possible.
 
> Several questions:
> 1. I need to prepare separate mapsheets of landcover data.  I have a
> vector layer in grass of all the boundingboxes.  How can I call ps.map
> to create mapsheets using the individual boundingboxes as the region
> settings?

hmmm how to extract the bounding box of each category in a vector map?
I think there might be a way, but I'm not sure, maybe someone else knows.

anyway you can write a shell loop to use v.extract to pull out that
one category and then use "g.region vect=extract_cat_$CAT" to zoom in
on that one area. If you want a buffer around it, try like:

g.region vect=$MAP
g.region res=5000 -a

which will grow outwards until it hits a 5km round number.

while you are there save the region with 'g.region save=' with a name
derived from that box name so you can jump to it quickly later on.

something like

for CAT in `v.category master_bounding_box_map option=print` ; do
   v.extract in=master_bounding_box_map out=bbox_$CAT list=$CAT
   g.region -d
   g.region vect=bbox_$CAT
   g.region res=5000 -a
   g.region res=10   # back to normal for raster map res
   g.region save=bbox_$CAT
done

then

for REGION in `g.mlist region pattern=bbox_*` ; do
   g.region region=$REGION
   ps.map out=landcover_$REGION in=- << EOF
       ....
       end
EOF
   ps2pdf landcover_$REGION.ps
done



> 2. Each mapsheet requires a different locatormap as reference.  How
> do I add the locatormap using a bigger region settings around
> the mapped region settings?

inlays:
first for each mapsheet save a region with 'g.region save='.
then (in a loop) create a ps.map .eps file drawing the overview
map but also using the ps.map "region" instruction to draw a box
over the top of it. I like to use a red frame with width of 2,
but you'll have to experiment with the width as this .eps will be
much smaller on the page once it is embedded. Because it will be
so reduced you can probably set the resolution quite coarse, with
a little math you can figure out how many raster column cells equate
to 300dpi at your target width (e.g. if you want the inset to be 2"
wide set the region resolution to be so columns is about 600 cells.)

once you have those just use the ps.map 'eps' instruction to place
them on the map. Use the 'rectangle' instruction to add a thicker
border if you like.

again, if you write the script like this:

for MAP in `g.mlist rast patter=*.landuse` ; do
   case "$MAP" in
      landuse23)
         MAP_TITLE="Map of landuse category 23"
         ;;
       landuse24)
         MAP_TITLE= ...
         ;;
   esac

   ps.map out=$MAP.ps in=- << EOF
      raster $MAP
      eps 10% 10%
        epsfile locator_$MAP.eps
        scale 0.2
        end
      text 650000 7365000 Landuse for $MAP_TITLE
        end
      end
EOF

then you can use shell variable replacement within the instruction file.
another way is to have a shell script write a bunch of files instead of
running ps.map directly; or just make a master instruction file then copy
it a bunch of times and tweak each individually. that last way is a pain
if you decide to change anything though, as you have to make the edit
in every copy of the file.

you can put the non changing bits in a template file and then do like:

for MAP in `g.mlist` ; do
  ps.map out=test.ps in=- << EOF
     raster $MAP
     eps ..
       epsfile region.$MAP
       end
     `cat common_instructions.txt`
     end
EOF


> 3. Legend symbology for different landcover categories within a single
> polygon vector.  As a workaround, I separate landcover categories as
> separate vector layers.

you can keep them all in the same file, just repeat the vareas command
but limit by SQL query each time, and set the "label" for each vareas
as needed. see example here:
 http://grass.osgeo.org/wiki/Psmap_fill_patterns
 http://grass.osgeo.org/wiki/AreaFillPatterns


> 4. Tips and tricks for different annotations.

you'd have to be more specific about what you mean. many tips here:
  http://grass.osgeo.org/wiki/Ps.map
  http://grass.osgeo.org/wiki/IconSymbols#North_Arrows

see also ps.output in wiki addons.


> 5. Combine different ps.map output into one map.

see
 http://grass.osgeo.org/wiki/Ps.map_scripts#Multiple_raster_images



feel free to add anything useful to those wiki pages.


Hamish



      



More information about the grass-user mailing list