# Plot line width in unit of km

**URL:** <https://forum.generic-mapping-tools.org/t/plot-line-width-in-unit-of-km/826>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [August 29, 2020, 8:14am UTC](https://forum.generic-mapping-tools.org/t/plot-line-width-in-unit-of-km/826 "2020-08-29T08:14:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yangleir](https://avatars.discourse-cdn.com/v4/letter/y/a8b319/32.png) [@yangleir](https://forum.generic-mapping-tools.org/u/yangleir)\
**Post date:** [August 29, 2020, 8:14am UTC](https://forum.generic-mapping-tools.org/t/plot-line-width-in-unit-of-km/826/1 "2020-08-29T08:14:07Z")

</div>

Hi, everyone  
I hope to plot a line with width of 5km. Is there a simple way to do this job using GMT?  
The figure will look like:

 ![xmd](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/e92062e63e5d7932ffa53b5472f944ea07760837.png)

My method is not directly. I use the scale of map projection to do this.

```auto
#!/bin/bash
# This is the Fig 1 

R=120:22/120:41/35:55/36:06
J=m120:30/36/1:500000
# Here use the map scale not the width in map projection. This will allow the line width in cm unit to link to the geographical units km.
gmt gmtset MAP_FRAME_WIDTH = 0.001c FONT_ANNOT_PRIMARY	= 7p
PS=xmd.ps
gmt psbasemap -R$R -J$J -P -K -Lx0.3i/0.3i+c120/36+w5k >$PS
gmt pscoast -R$R -J$J -O -Df -W -I1 -K -Bpxa5mf -Bpya5mf -BnWSe -Glightyellow >> $PS
echo 120.41099 36.053231 > tmp.d
echo 120.65269 35.968024 >>tmp.d
gmt psxy tmp.d -W1c,black -R$R -J$J -P -O -K -t70 >> $PS
gmt psxy tmp.d -W0.01c,black+ve0.1i+gblue -R$R -J$J -P -O >> $PS

gmt psconvert $PS -A -P -Tg
rm gmt.* *.ps tmp*

```

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [August 31, 2020, 4:56am UTC](https://forum.generic-mapping-tools.org/t/plot-line-width-in-unit-of-km/826/2 "2020-08-31T04:56:56Z")

</div>

There is no option to say -W5k for a 5 km pen since it depends on projection. But, in such a small region, the map scale does not vary much. So if you use 1:500000 that means 1 cm on the plot is 500000 cm or 5 km. So drawing a line with a 1c pen will be very close anywhere in your map.
