Ps.map graph paper: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(→‎See also: (screenshot desired))
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Creating graph paper with ps.map ==
== Creating graph paper with ps.map ==


The {{cmd|ps.map}} module is quite flexible. This example will demonstrate how to use it to create some graph paper and save it into a PostScript or PDF file ready for printing. With some slight tweaks you can make A3, Legal-sized, etc. paper with the grid resolution of your choosing.
The {{cmd|ps.map}} module is quite flexible. This example will demonstrate how to use it to create your own graph paper (free!) and save it into a PostScript or PDF file ready for printing whenever you need it. With some slight tweaks you can make A3, Legal-sized, etc. paper with the grid resolution of your choosing.
 
This is not the most efficient method, but it's just a demonstration after all. If it were more efficient I'd include the PDFs on this page for you to download directly, but it's easy enough to cut and paste the examples below.


This is not the most efficient method, but it's just a demonstration after all.


=== Background ===
=== Background ===
Line 15: Line 16:
* 25.4 mm = 1"
* 25.4 mm = 1"


* The aspect ratio of metric paper sizes is length = width * sqrt(2).
* The aspect ratio of metric paper sizes is: <tt>length = width * sqrt(2)</tt>.


=== Creating graph paper with a 1/4 inch grid ===
=== Creating graph paper with a 1/4 inch grid ===
Line 33: Line 34:


* set region:  
* set region:  
: Here we will want to calculate the size of the grid canvas. It will be a little smaller than the paper size. So given the above dimensions Letter-sized paper with 1/2" margins on the sizes and 1" on the top and the bottom, the grid canvas will be 7.5" x 9". So set north=9, south=0, west=0, and east=7.5. Set the resolution to 0.25. The exact default region is not important, it's just to get us started.
: Here we will want to calculate the size of the grid canvas. It will be a little smaller than the paper size. So given the above dimensions for Letter-sized paper with 1/2" margins on the sizes and 1" on the top and the bottom, the grid canvas will be 7.5" x 9". So set north=9, south=0, west=0, and east=7.5. Set the resolution to 0.25. The exact default region is not important, it's just to get us started.


<!--
<!--
Line 172: Line 173:
  Enter conversion factor from millimeters to meters: 0.001
  Enter conversion factor from millimeters to meters: 0.001


This time we set the default region to canvas size in mm. The canvas size for our 1/4" grid was just about right so we'll reuse that: <tt>9" * 25.4 = 228.6mm</tt>, <tt>7.5 * 25.4 = 190.5mm</tt>. Rounding to the nearest cm that's 230mm x 190mm. So the region is:
This time we set the default region to canvas size in mm. The canvas size for our 1/4" grid was just about right so we'll reuse that: <tt>9" * 25.4 = 228.6mm</tt>, and <tt>7.5 * 25.4 = 190.5mm</tt>. Rounding to the nearest cm that's 230mm x 190mm. So the region is:


  n=230  s=0  w=0  e=190  res=1
  n=230  s=0  w=0  e=190  res=1
Line 198: Line 199:


This time we have to do a little math to calculate how big the margins should be to keep the grid canvas centered on the page:
This time we have to do a little math to calculate how big the margins should be to keep the grid canvas centered on the page:
   width of grid: 180 mm / 2.54 = 7.087"
   width of grid: 180 mm / 25.4 = 7.087"
   ( width a4 - width grid ) / 2 = 0.59" margins
   ( width a4 - width grid ) / 2 = 0.59" margins


Line 238: Line 239:


If you want to keep the PostScript file you might use `ps2ps` to shrink it. The 1mm fine vector mesh map can make the file pretty huge. Simply zipping it helps too.
If you want to keep the PostScript file you might use `ps2ps` to shrink it. The 1mm fine vector mesh map can make the file pretty huge. Simply zipping it helps too.


==== On Letter paper ====
==== On Letter paper ====
Line 246: Line 246:


And recalculate the margin size:
And recalculate the margin size:
   width grid: 190 mm / 2.54 = 7.48"
   width grid: 190 mm / 25.4 = 7.48"
   ( width letter - width grid ) / 2 = 0.51" margins
   ( width letter - width grid ) / 2 = 0.51" margins


Line 284: Line 284:
Convert to PDF:
Convert to PDF:
  ps2pdf mm_letter.ps
  ps2pdf mm_letter.ps
== More ideas ==
For a cleaner page you might try replacing the vector grid and '''grid''' line instruction with a series of crosses:
grid 10
  color black
  cross 1
  width 0.5
  end
or fiducial marks:
vpoints two_inch_grid
  type centroid
  symbol extra/fiducial
  rotate 45
  color black
  size 8
  width 0.2
  end


== See also ==
== See also ==
Line 291: Line 313:


[[Category: ps.map]]
[[Category: ps.map]]
[[Category: Documentation]]
[[Category: Printing]]

Latest revision as of 20:50, 2 August 2013

Creating graph paper with ps.map

The ps.map module is quite flexible. This example will demonstrate how to use it to create your own graph paper (free!) and save it into a PostScript or PDF file ready for printing whenever you need it. With some slight tweaks you can make A3, Legal-sized, etc. paper with the grid resolution of your choosing.

This is not the most efficient method, but it's just a demonstration after all. If it were more efficient I'd include the PDFs on this page for you to download directly, but it's easy enough to cut and paste the examples below.


Background

Some useful numbers and facts to know before we start:

  • PostScript's (and thus PDF's) natural unit is the point. As in a "10 point" font size. A point is 1/72 of an inch, and so a 72 point font is 1" tall when printed. So for PostScript tasks it is both common and easiest to work directly with inches.
  • A sheet of A4 paper is 8.268" x 11.693". A sheet of Letter sized paper is 8.5" x 11".
  • 25.4 mm = 1"
  • The aspect ratio of metric paper sizes is: length = width * sqrt(2).

Creating graph paper with a 1/4 inch grid

First create a new location using inches as the base unit.

Assuming you used the text-based interactive startup wizard:

  • Create a new location
  • [D] - Other projection
  • Projection: eqc (Plate Caree)
  • No datum
  • Ellipsoid: sphere
  • Radius of Earth: just use the default
  • Latitude, Longitude of center.. just set to 0.0
  • Enter plural form of units [meters]: inches
  • Enter conversion factor from inches to meters: 0.0254
  • set region:
Here we will want to calculate the size of the grid canvas. It will be a little smaller than the paper size. So given the above dimensions for Letter-sized paper with 1/2" margins on the sizes and 1" on the top and the bottom, the grid canvas will be 7.5" x 9". So set north=9, south=0, west=0, and east=7.5. Set the resolution to 0.25. The exact default region is not important, it's just to get us started.


Next start up GRASS in a new mapset in this new location.


While the d.grid command can be used multiple times at different grid distances, unfortunately ps.map's grid instuction can only be used once. You can use v.mkgrid to make a grid pattern though, so first we'll use that to make copies of two grid sizes.

v.mkgrid inch_grid grid=9,7 position=coor coor=0,0 box=1,1

g.region -p # check that res=0.25; read rows,cols for grid option
v.mkgrid quarter_inch_grid grid=36,30

This will let us draw a 1" black grid over the top of a 1/4" grey grid for a nice effect.

If you were just displaying to the screen you could have done:

d.grid 0.25 -b -t color=220:220:220
d.grid 1


On A4 paper

For A4 paper we'll use a 1/2" margin on the left and right, a 1" margin on the top, and a bit of a bigger margin on the bottom to leave room for a ruler.

So we are left with 8.268" - (2 * 0.5") = 7.268" wide and 11.693" - 1" - 1.5" = 9.193" tall. To maintain whole grid boxes we'll round this down to 7.25" x 9".

g.region  n=9 s=0 w=0 e=7.25 res=0.25

And save it as a named region for future reference.

g.region save=a4

With all that set up we can run ps.map. The map scale is 1:1, we use the vector grid we made with v.mkgrid to render the finer mesh, and the grid instruction to render the darker 1" overlay grid. Finally we'll place a 5" ruler at the bottom of the page with the scalebar instruction.

ps.map out=quarter_inch_a4.ps << EOF

paper a4
  left 0.5
  right 0.5
  top 1.0
  bottom 1.5
  end

scale 1:1

vareas quarter_inch_grid
  fcolor none
  color grey
  width 0.5
  end

grid 1
  color black
  width 0.5
  end

scalebar s
  where 4.134 10.75
# (4.134 is width a4 / 2, so the center of the page)
  length 5
  segment 20
  numbers 4
  end

end

EOF


You can convert PostScript to PDF with the `ps2pdf` program that comes with Ghostscript:

ps2pdf quarter_inch_a4.ps

On Letter paper

This is mostly the same, we just modify the margins a bit and the region to match. This time the margin math is a bit simpler.

11" tall - margins = 9" grid canvas height

8.5" wide - 1/2" margins = 7.5" grid canvas width

So we (re)set the region to these numbers: (just 1/4" wider than the A4 one)

g.region n=9 e=7.5

And save it for future reference:

g.region save=letter

And again we run ps.map with a similar set of commands:

ps.map out=quarter_inch_letter.ps << EOF

paper us-letter
  left 0.5
  right 0.5
  top 0.75
  bottom 1.25
  end
scale 1:1
vareas quarter_inch_grid
  fcolor none
  color grey
  width 0.5
  end
grid 1
  color black
  width 0.5
  end
scalebar s
  where 4.25 10.35
# 4.25 = width letter / 2
  length 5
  segment 20
  numbers 4
  end
end

EOF

And convert the PostScript output to a PDF:

ps2pdf quarter_inch_letter.ps

Creating graph paper with a 1 mm grid

To create graph paper with a 1 mm grid (and 1 cm dark-line overlay) create another custom location, but this time use millimeters as the unit.

Enter plural form of units [meters]: millimeters
Enter conversion factor from millimeters to meters: 0.001

This time we set the default region to canvas size in mm. The canvas size for our 1/4" grid was just about right so we'll reuse that: 9" * 25.4 = 228.6mm, and 7.5 * 25.4 = 190.5mm. Rounding to the nearest cm that's 230mm x 190mm. So the region is:

n=230  s=0  w=0  e=190  res=1

Once in the region we make our vector grids, first the 1cm x 1cm grid:

v.mkgrid cm_grid grid=23,19 position=coor coor=0,0 box=10,10

Then the 1mm grid:

g.region -p # read rows,cols
# that adds up to a lot of boxes, so we consolidate it internally
v.mkgrid mm_grid_raw grid=230,190
v.build.polylines in=mm_grid_raw out=mm_grid
g.remove vect=mm_grid_raw


On A4 paper

A4 paper is a little narrower, so we chop off a 1cm column:

g.region n=230 e=180 s=0 w=0 res=1

And save it in case we want to go back to it later,

g.region save=a4

This time we have to do a little math to calculate how big the margins should be to keep the grid canvas centered on the page:

 width of grid: 180 mm / 25.4 = 7.087"
 ( width a4 - width grid ) / 2 = 0.59" margins

The rest is the same as before- draw the fine grid then the darker 10mm grid over the top of it.

ps.map out=mm_a4.ps << EOF

paper a4
  left 0.59
  right 0.59
  top 1.0
  bottom 1.5
  end
scale 1:1
vareas mm_grid
  fcolor none
  color 180:180:180
  width 0.5
  end
grid 10
  color black
  width 0.5
  end
scalebar s
  where 4.134 10.75
# 4.134 = width a4 / 2
  length 100
  segment 10
  numbers 2
  end
end

EOF

Convert PostScript to PDF:

ps2pdf mm_a4.ps

If you want to keep the PostScript file you might use `ps2ps` to shrink it. The 1mm fine vector mesh map can make the file pretty huge. Simply zipping it helps too.

On Letter paper

We set the region size back a little bit wider:

g.region n=230 e=190 s=0 w=0 res=1

And recalculate the margin size:

 width grid: 190 mm / 25.4 = 7.48"
 ( width letter - width grid ) / 2 = 0.51" margins

And run ps.map:

ps.map out=mm_letter.ps << EOF

paper us-letter
  left 0.51
  right 0.51
  top 0.75
  bottom 1.25
  end
scale 1:1
vareas mm_grid
  fcolor none
  color 180:180:180
  width 0.5
  end
grid 10
  color black
  width 0.5
  end
scalebar s
  where 4.25 10.35
# 4.25 = width letter / 2
  length 100
  segment 10
  numbers 2
  end
end

EOF

Convert to PDF:

ps2pdf mm_letter.ps

More ideas

For a cleaner page you might try replacing the vector grid and grid line instruction with a series of crosses:

grid 10
  color black
  cross 1
  width 0.5
  end

or fiducial marks:

vpoints two_inch_grid
  type centroid
  symbol extra/fiducial
  rotate 45
  color black
  size 8
  width 0.2
  end


See also

  • I'm pretty sure GMT has a graph paper demo; if so I got the idea for this demo from them. (link?)