Ps.out Making maps: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(Created page with "== Making maps with same layout using ps.out == To make several maps with the same layout, we use three files: map_pre, map_post, and a master file. Also we need the map_# with ...")
 
No edit summary
 
(41 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Making maps with same layout using ps.out ==
= How make a map? =
To make several maps with the same layout, we use three files: map_pre, map_post, and a master file.
Also we need the map_# with the particular content of the map.


The '''master file''', to repeat the creation of all maps with the same layout, is as:
== The header of file ==


<source lang="bash">
  #!/bin/bash
  #!/bin/bash


MAP=map_ps
=== Command line ===
function makemap()
 
{
First I define a variable to store the name of the output because when I want change it I modify only this value. Also, begin the '''ps.out''' command and the EOF block.
    echo "#!/bin/bash" > $MAP
    cat map_pre  >> $MAP
    cat $1 >> $MAP
    cat map_post >> $MAP
    chmod +x $MAP
    ./$MAP $1
    rm $MAP
}


  makemap map_1
  OUTPUT="OUT"
makemap map_2
  ps.out -g out=$OUTPUT.ps << EOF
  </source>


----
== The layout ==


The file '''map_pre''' include all code to execute ''ps.out'' and design the basic elements of the map: title, graticule, scalebar, north-arrow, etc.
A example content is:


<source lang="bash">
=== The paper ===
OUTPUT=$1
ps.out -g out=$OUTPUT.ps << EOF


  paper A4
  paper A4
     left 2cm
     left 1in
    top 2cm
     landscape y
     landscape y
    font
      name Univers
      size 9
    end
     draw
     draw
      color 70:70:70
        color black ~ linewidth .8mm
      linewidth .4mm
        moveto 23cm 1.5cm ~ fcolor 220:220:220 ~ rect 29cm 19cm
      rect 22cm 2cm 28cm 19cm 240:240:240
        moveto 23cm 1.5cm ~ fcolor 100:100:100 ~ rect 29cm 4cm
         color black
         font Univers-Bold 14 extend 2 ~ color white
         font OffensiveBold 10 .8
         moveto 26cm 2.25cm ~ text :Making|.maps with|ps.out
        text 25cm 6cm "MAIN TITLE"
     end
     end
  end
  end


  scale 1:500000
=== Placing the map area on the page ===
 
I prefer use the default values of the '''map area''' but to show anything I set the color of the border map.
 
maparea
    color white
end
 
I request a fixed '''scale''' for the map.
 
  scale 1:100000
 
=== Elements on the map ===
 
The '''border of the map''' is a usual elements to geographically locate the map. There is not a default border then if you want it you need define this stament.


  grid
  grid
     format iho
     format iho
    trim -1
     major 10000
     major 50000
         width .1mm
         width .18mm
        color indigo$.25
    end
    minor 5000
         color none
         color none
     end
     end
     minor 25000
end
         width .18mm
 
         color none
The '''scalebar''' is also an usual elements.
         style 2
 
scalebar S
    units km Km
    length 5
    major 5 1
     minor 0 5
    frame
         where 26cm 17cm
        ref center center
         border 0
         fcolor none
     end
     end
     subminor 5
     height 3mm
     font
end
         name Univers
 
         size 10
The '''numeric scale''' is also usefull. As you can see, I request a ''scale 1:100000'' but with the actual margins and border the minimun scale is 1:110249.
         color black
 
note :scale escala
     frame
        where 26cm 17cm
        ref center upper
         border 0
         margin 10
         fcolor none
     end
     end
    fcolor black
  end
  end


vlines bz_lim
== The first output ==
  type boundary
 
  label Límite del Bierzo
At this moment this is the output:
  lpos -1
 
  line
[[File:ps_out_first.png|center]]
    width .3mm
 
    color black
== Composing the map ==
  end
 
=== The background of the map ===
 
The '''raster file''' is a frequent element and, for the moment, it is necessary to mask vector maps. Here I use a shaded raster to make the aspect of 3D in this simple how to.
 
raster bz_30m_shade
  end
  end
</source>


----
The output in console show me that the equivalent quality is 93 ppi. Changing the resolution with ''[[g.region]] res=10'' you can add pixels to slowup the printing quality (if you raster have the request resolution!).


The file '''map_post''' include the final ending code, and perhaps the common legend style. For example,
=== The vector in the map ===
 
Now, I add the '''vector file'''. Here it is a vector with contour lines.


  <source lang="bash">
  vlines test_contour@bierzo
vlegend Legend
     line
     frame
         width .1mm
         where 25cm 12cm
         color OR8
        ref center center
        offset 0 0
        border .3mm
        fcolor white
         margin 12
     end
     end
     title
     rgbcol - level
        name Univers-Bold
    setcolor 600,1000:OR8|.3mm main contour lines
        size 10
end
        extend 1.25
 
     end
In this code ''OR8'' is a color defined in a ''palette'' block (do not shown in the code) but the most important is the extended form of the command ''setcolor'' to change the width of the specific contour lines with a ''level'' value of 600 or 1000.
     font
 
        name Univers
== The second output ==
         size 9
 
Now the output is:
 
[[File:ps_out_second.png|center]]
 
== Decorations ==
 
The '''legend''' is another usefull component but in this map is not necessary. After, the legend is showed when I will change to a colored version.
 
The only decoration in this howto will be the '''north arrow''' and some free '''text''' using the ''draw'' commend with the option of free to can place the north arrow outside of the map area.
 
draw free
    color black
    font Univers 12 2
    moveto 9cm 6cm ~ text .E l  B i e r z o
    moveto 11cm 16cm ~ otext 12cm 90 Montes Aquilianos
    font Bitstream-Vera-Serif 10 1.2
    moveto 697000 4714200 ~ text .Ponferrada
   
    font Univers 10 extend 1.5 ~ color 100:100:100
     moveto 26cm 14cm ~ north #
     font Univers 8 2
    moveto 23cm 19.5cm ~ text UTM 29 : ellipsoid ETRS89
end
 
Well, I also add some of colour with a '''vector map''' of edifications.
 
vareas bz_edific
    line
         color none
     end
     end
    fcolor red
  end
  end
== The third output ==
[[File:ps_out_third.png|center]]
== The footer of the file ==
Now, I '''finish''' the EOF stament.


  EOF
  EOF


echo "GO Go go: $OUTPUT.pdf"
I prefer work with '''PDF''' than ''PS'' because I see the transparent colours and it compress the file resulting in a considerably smalles file size.
 
  ps2pdf14 $OUTPUT.ps
  ps2pdf14 $OUTPUT.ps
</source>


----
== A colored final output ==


The file '''map_#''' include the specific code to draw the particular maps. For example,
A colored version using the ''raster'' map bz_30m, runnig ''[[r.colors]] map=bz_30m color=haxby'' and adding ''rlegend'' and some changes of the colors.
 
raster bz_30m bz_30m_shade
end
   
   
  <source lang="bash">
  rlegend
vareas risk_range
    raster bz_30m
  label Probabilidad de infección
    frame
  legend 0
        where 26cm 5cm
  line
        ref center upper
    width .01mm
        fcolor none
    color none
        border 0
    style 1
     end
     end
     fcolor GRASSRGB$.7 cat
     swidth .5cm
     masked y
     tick 2mm
     setrule 1 Muy baja
     height 8cm
    setrule 2 Baja
    setrule 3 Media
    setrule 4 Alta
    setrule 5 Muy alta
  end
  end


[[File:ps_out_final.png|center]]
= Maps with same layout =
To make several maps with the same layout, we use three files: map_pre, map_post, and a master file.
Also we need the map_# with the particular content of the map.
== The master file ==
The '''master file''', to repeat the creation of all maps with the same layout, is as:
  #!/bin/bash
MAP="_ps_"
function makemap()
  {
    echo "#!/bin/bash" > $MAP
    cat map_pre  >> $MAP
    cat $1 >> $MAP
    cat map_post >> $MAP
    chmod +x $MAP
    ./$MAP $1
    rm $MAP
  }
  makemap map_1
  makemap map_2
== The first part ==
The file '''map_pre''' include all code to execute ''ps.out'' and design the basic elements of the map: title, border, scalebar, north-arrow, etc.
A example content is:
  OUTPUT=$1
  ps.out -g out=$OUTPUT.ps << EOF
 
  paper A4
    ''[...]''
  end
  scale 1:500000
  grid
    ''[...]''
  end
 
  vlines bz_lim
    ''[...]''
  end
== The specific part of the map ==
The file '''map_#''' include the specific code to draw the particular maps.
vareas risk_range
    ''[...]''
end
  vpoint cs_parcela
  vpoint cs_parcela
     label Intensidad de ataque
     ''[...]''
    where ch_pr > 0
end
    symbol basic/circle
 
    line
== The last part ==
        width .1mm
 
        color black
The file '''map_post''' include the final ending code, and perhaps the common legend style. For example,
    end
 
     fcolor white$.3
  vlegend Legend
    size ch_prx 8
     ''[...]''
    scale 5 2
  end
     masked y
draw free
     ''[...]''
  end
  end
  </source>
   
  EOF
  ps2pdf14 $OUTPUT.ps
 
   
   


[[Category: ps.map]]
[[Category: ps.map]]
[[Category: HowTo]]

Latest revision as of 07:19, 29 August 2013

How make a map?

The header of file

#!/bin/bash

Command line

First I define a variable to store the name of the output because when I want change it I modify only this value. Also, begin the ps.out command and the EOF block.

OUTPUT="OUT"
ps.out -g out=$OUTPUT.ps << EOF

The layout

The paper

paper A4
   left 1in
   landscape y
   font
     name Univers
     size 9
   end
   draw
       color black ~ linewidth .8mm
       moveto 23cm 1.5cm ~ fcolor 220:220:220 ~ rect 29cm 19cm
       moveto 23cm 1.5cm ~ fcolor 100:100:100 ~ rect 29cm 4cm
       font Univers-Bold 14 extend 2 ~ color white
       moveto 26cm 2.25cm ~ text :Making|.maps with|ps.out
   end
end

Placing the map area on the page

I prefer use the default values of the map area but to show anything I set the color of the border map.

maparea
   color white
end

I request a fixed scale for the map.

scale 1:100000

Elements on the map

The border of the map is a usual elements to geographically locate the map. There is not a default border then if you want it you need define this stament.

grid
   format iho
   major 10000
       width .1mm
       color indigo$.25
   end
   minor 5000
       color none
   end
end

The scalebar is also an usual elements.

scalebar S
   units km Km
   length 5
   major 5 1
   minor 0 5
   frame
       where 26cm 17cm
       ref center center
       border 0
       fcolor none
   end
   height 3mm
end

The numeric scale is also usefull. As you can see, I request a scale 1:100000 but with the actual margins and border the minimun scale is 1:110249.

note :scale escala
   frame
       where 26cm 17cm
       ref center upper
       border 0
       margin 10
       fcolor none
   end
end

The first output

At this moment this is the output:

Composing the map

The background of the map

The raster file is a frequent element and, for the moment, it is necessary to mask vector maps. Here I use a shaded raster to make the aspect of 3D in this simple how to.

raster bz_30m_shade
end

The output in console show me that the equivalent quality is 93 ppi. Changing the resolution with g.region res=10 you can add pixels to slowup the printing quality (if you raster have the request resolution!).

The vector in the map

Now, I add the vector file. Here it is a vector with contour lines.

vlines test_contour@bierzo
   line
       width .1mm
       color OR8
   end
   rgbcol - level
   setcolor 600,1000:OR8|.3mm main contour lines
end

In this code OR8 is a color defined in a palette block (do not shown in the code) but the most important is the extended form of the command setcolor to change the width of the specific contour lines with a level value of 600 or 1000.

The second output

Now the output is:

Decorations

The legend is another usefull component but in this map is not necessary. After, the legend is showed when I will change to a colored version.

The only decoration in this howto will be the north arrow and some free text using the draw commend with the option of free to can place the north arrow outside of the map area.

draw free
   color black
   font Univers 12 2
   moveto 9cm 6cm ~ text .E l  B i e r z o
   moveto 11cm 16cm ~ otext 12cm 90 Montes Aquilianos
   font Bitstream-Vera-Serif 10 1.2
   moveto 697000 4714200 ~ text .Ponferrada
   
   font Univers 10 extend 1.5 ~ color 100:100:100
   moveto 26cm 14cm ~ north #
   font Univers 8 2
   moveto 23cm 19.5cm ~ text UTM 29 : ellipsoid ETRS89
end

Well, I also add some of colour with a vector map of edifications.

vareas bz_edific
   line
       color none
   end
   fcolor red
end

The third output

The footer of the file

Now, I finish the EOF stament.

EOF

I prefer work with PDF than PS because I see the transparent colours and it compress the file resulting in a considerably smalles file size.

ps2pdf14 $OUTPUT.ps

A colored final output

A colored version using the raster map bz_30m, runnig r.colors map=bz_30m color=haxby and adding rlegend and some changes of the colors.

raster bz_30m bz_30m_shade
end

rlegend
   raster bz_30m
   frame
       where 26cm 5cm
       ref center upper
       fcolor none
       border 0
   end
   swidth .5cm
   tick 2mm
   height 8cm
end

Maps with same layout

To make several maps with the same layout, we use three files: map_pre, map_post, and a master file. Also we need the map_# with the particular content of the map.

The master file

The master file, to repeat the creation of all maps with the same layout, is as:

 #!/bin/bash

MAP="_ps_"
function makemap()
 {
   echo "#!/bin/bash" > $MAP
   cat map_pre  >> $MAP
   cat $1 >> $MAP
   cat map_post >> $MAP
   chmod +x $MAP
   ./$MAP $1
   rm $MAP
 }

 makemap map_1
 makemap map_2

The first part

The file map_pre include all code to execute ps.out and design the basic elements of the map: title, border, scalebar, north-arrow, etc. A example content is:

 OUTPUT=$1
 ps.out -g out=$OUTPUT.ps << EOF
 
 paper A4
   [...]
 end

 scale 1:500000

 grid
   [...]
 end
 
 vlines bz_lim
   [...]
 end

The specific part of the map

The file map_# include the specific code to draw the particular maps.

vareas risk_range
   [...]
end

vpoint cs_parcela
   [...]
end

The last part

The file map_post include the final ending code, and perhaps the common legend style. For example,

 vlegend Legend
   [...]
 end

draw free
   [...]
end

 EOF

 ps2pdf14 $OUTPUT.ps