Ps.out Making maps: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
No edit summary
 
(28 intermediate revisions by one other user not shown)
Line 5: Line 5:
  #!/bin/bash
  #!/bin/bash


=== Command line options ===
=== 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"
  OUTPUT="OUT"
Line 31: Line 33:
  end
  end


=== Placing the map ===
=== 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
  maparea
    border .8mm
     color white
     color white
  end
  end
I request a fixed '''scale''' for the map.


  scale 1:100000
  scale 1:100000
Line 42: Line 47:
=== Elements on the map ===
=== Elements on the map ===


The '''border of the map''' is a usual elements to geographically locate the map. There is a default border but I'm like the iho format.
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
Line 58: Line 63:


  scalebar S
  scalebar S
     units km km
     units km Km
     length 5
     length 5
     major 5 1
     major 5 1
Line 71: Line 76:
  end
  end


The '''numeric scale'' is also usefull. As you can see, I request a ''scale 1:100000'' but with the actual margins the minimun scale is 1:110249.
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
  note :scale escala
Line 83: Line 88:
  end
  end


== Code for the map ==
== The first output ==
 
At this moment this is the output:
 
[[File:ps_out_first.png|center]]
 
== 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:
 
[[File:ps_out_second.png|center]]


== Decorations ==
== Decorations ==


== the footer of the file ==
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 ==
 
[[File:ps_out_third.png|center]]
 
== The footer of the file ==
 
Now, I '''finish''' the EOF stament.


  EOF
  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
  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
[[File:ps_out_final.png|center]]


= Maps with same layout =
= Maps with same layout =
Line 97: Line 195:
Also we need the map_# with the particular content of the map.
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:
The '''master file''', to repeat the creation of all maps with the same layout, is as:


<source lang="bash">
  #!/bin/bash
#!/bin/bash
 
  MAP="_ps_"
  MAP=map_ps
  function makemap()
  function makemap()
{
  {
     echo "#!/bin/bash" > $MAP
     echo "#!/bin/bash" > $MAP
     cat map_pre  >> $MAP
     cat map_pre  >> $MAP
Line 112: Line 210:
     ./$MAP $1
     ./$MAP $1
     rm $MAP
     rm $MAP
}
  }
 
makemap map_1
  makemap map_1
makemap map_2
  makemap map_2
</source>


----
== The first part ==


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.
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:
A example content is:


<source lang="bash">
  OUTPUT=$1
OUTPUT=$1
  ps.out -g out=$OUTPUT.ps << EOF
ps.out -g out=$OUTPUT.ps << EOF
 
  paper A4
    ''[...]''
  end
  scale 1:500000
  grid
    ''[...]''
  end
 
  vlines bz_lim
    ''[...]''
  end


paper A4
== The specific part of the map ==
    left 2cm
    top 2cm
    landscape y
    draw
      color 70:70:70
      linewidth .4mm
      rect 22cm 2cm 28cm 19cm 240:240:240
        color black
        font OffensiveBold 10 .8
        text 25cm 6cm "MAIN TITLE"
    end
end


  scale 1:500000
The file '''map_#''' include the specific code to draw the particular maps.
 
   
  grid
  vareas risk_range
     format iho
     ''[...]''
    trim -1
    major 50000
        width .18mm
        color none
    end
    minor 25000
        width .18mm
        color none
        style 2
    end
    subminor 5
    font
        name Univers
        size 10
        color black
    end
    fcolor black
  end
  end
 
  vlines bz_lim
  vpoint cs_parcela
  type boundary
    ''[...]''
  label Límite del Bierzo
  lpos -1
  line
    width .3mm
    color black
  end
  end
  end
</source>


----
== The last part ==


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


<source lang="bash">
  vlegend Legend
vlegend Legend
     ''[...]''
     frame
  end
        where 25cm 12cm
        ref center center
draw free
        offset 0 0
     ''[...]''
        border .3mm
        fcolor white
        margin 12
    end
    title
        name Univers-Bold
        size 10
        extend 1.25
    end
    font
        name Univers
        size 9
     end
  end
  end
EOF
echo "GO Go go: $OUTPUT.pdf"
ps2pdf14 $OUTPUT.ps
</source>
----
The file '''map_#''' include the specific code to draw the particular maps. For example,
   
   
<source lang="bash">
  EOF
  vareas risk_range
   
  label Probabilidad de infección
  ps2pdf14 $OUTPUT.ps
  legend 0
   
  line
    width .01mm
    color none
    style 1
    end
    fcolor GRASSRGB$.7 cat
    masked y
    setrule 1 Muy baja
    setrule 2 Baja
    setrule 3 Media
    setrule 4 Alta
    setrule 5 Muy alta
  end


vpoint cs_parcela
    label Intensidad de ataque
    where ch_pr > 0
    symbol basic/circle
    line
        width .1mm
        color black
    end
    fcolor white$.3
    size ch_prx 8
    scale 5 2
    masked y
end
</source>
   
   


[[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