# PLot network from points to points

**URL:** <https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723>\
**Category:** Q&A\
**Created:** [March 21, 2022, 12:33am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723 "2022-03-21T00:33:14Z")\
**Posts on this page:** 12\
**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:** [March 21, 2022, 12:33am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/1 "2022-03-21T00:33:14Z")

</div>

Hi, all

Could GMT read following format and plot network from points (First -second columns) to points (third-fouth columns)? And the line width is set by the last column.

```auto
Latitude	Longitude	Latitude	Longitude	Frequency
37.09024	-95.712891	35.86166	104.195397	351
37.09024	-95.712891	46.227638	2.213749	336
37.09024	-95.712891	55.378051	-3.435973	218
37.09024	-95.712891	51.165691	10.451526	150
46.227638	2.213749	55.378051	-3.435973	131
46.227638	2.213749	51.165691	10.451526	121
55.378051	-3.435973	51.165691	10.451526	116
46.227638	2.213749	41.87194	12.56738	113
37.09024	-95.712891	56.130366	-106.346771	110
37.09024	-95.712891	-25.274398	133.775136	107
46.227638	2.213749	40.463667	-3.74922	103
55.378051	-3.435973	41.87194	12.56738	90
37.09024	-95.712891	36.204824	138.252924	83
37.09024	-95.712891	52.132633	5.291266	81
55.378051	-3.435973	-25.274398	133.775136	80
37.09024	-95.712891	41.87194	12.56738	78
...

```

And the map looks:

 ![QQ截图20220321083055](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/9/92fbdb4b1919379d134f4d46f5485025055cb50b.jpeg)

---

<div class="post-metadata">

**Author:** ![biggle1856](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/biggle1856/32/3169_2.png) [@biggle1856](https://forum.generic-mapping-tools.org/u/biggle1856)\
**Post date:** [March 21, 2022, 8:30am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/2 "2022-03-21T08:30:42Z")

</div>

yes, but you have to send the data to plot in the format it expects.  
I would do something like :  
awk ‘NR\>0{printf("\>-W%.2fp,red\n%s\t%s\n%s\t%s\n",$5/1e2,$1,$2,$3,$4)}’ datafile.dat | gmt plot

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [March 21, 2022, 8:37am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/3 "2022-03-21T08:37:57Z")

</div>

Here’s a start. Does not not take into account the width in the last column.  
I thought I could do both line and point within the same loop, but got into problems.

```auto
gmt begin lines png

gmt set GMT_THEME minimal

gmt psbasemap -B -JM15c -R-180/180/-80/80
gmt coast -Ggray

# plot lines
while read line;
do
awk '{ printf "%s %s\n%s %s\n", $2,$1,$4,$3}' | gmt plot -W
done < data

# plot red dots
while read line;
do
awk '{ printf "%s %s\n%s %s\n", $2,$1,$4,$3}' | gmt plot -Sc0.2c -Gred -W
done < data

gmt end show

```

 ![lines](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/8/8bba48df0737a1c1e283ec09a97d692760c70a9e.png)

---

<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:** [March 21, 2022, 8:53am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/4 "2022-03-21T08:53:02Z")

</div>

Might work directly on the file with -S=1p+s I think. We have no mechanism for changing the pen thickness but you could do something like

awk ‘{ printf “\> -W%gp\n%s\n”, $5\*0.01, $0}’ | gmt plot -S=1p+s -Vthin …

where you would have to figure out a good scale (here 0.01 was used) for scaling your frequency to pen width in points.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [March 21, 2022, 8:55am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/5 "2022-03-21T08:55:26Z")

</div>

A question regarding `-R`: It’s not possible to give an `-R` of, say, `-R0/720/-80/80` that would ‘print the world’ two consecutive times, right? Maybe this would be nice for some plots.

```auto
$ gmt coast -pdf test -R0/720/-80/80 -W
coast [ERROR]: Map region exceeds 360 degrees
coast [ERROR]: General map projection error

```

---

<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:** [March 21, 2022, 8:58am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/6 "2022-03-21T08:58:30Z")

</div>

I know, but too hard to change for us. Just do it with two plots.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [March 21, 2022, 9:08am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/7 "2022-03-21T09:08:43Z")

</div>

I see.

```auto
gmt begin worldx3 png

gmt set GMT_THEME minimal

gmt coast -W -JM10c -R0/360/-70/70 -BWSN
gmt coast -Wred -JM10c -R0/360/-70/70 -X10c -BSN
gmt coast -Wblue -JM10c -R0/360/-70/70 -X10c -BSEN

gmt end show

```

 ![worldx3](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/406699ce80084d5f0f505c60a2ab4fc79637d2a9.png)

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [March 21, 2022, 12:12pm UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/8 "2022-03-21T12:12:37Z")

</div>

> [@Andreas](#):
>
> ```auto
> gmt coast -Wblue -JM10c -R0/360/-70/70 -X10c -BSEN
> 
> ```

Just in case. You could use `-Xw` (instead of `-X10c`).

---

<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:** [March 21, 2022, 2:25pm UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/9 "2022-03-21T14:25:01Z")

</div>

Thanks all !  
I can figure out this using other tools (this one is used `Bibliometrix`). But, I am always looking for the possibility to use GMT to do this. Maybe I believe GMT can produce more beautiful maps.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [March 21, 2022, 7:47pm UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/10 "2022-03-21T19:47:23Z")

</div>

> [@yangleir](#):
>
> bibimetrix Python

Google doesn’t know it.

---

<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:** [March 21, 2022, 11:45pm UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/11 "2022-03-21T23:45:04Z")

</div>

Sorry. I am wrong.  
Bibliometrix:[https://www.bibliometrix.org/](https://www.bibliometrix.org/)

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [March 22, 2022, 7:23am UTC](https://forum.generic-mapping-tools.org/t/plot-network-from-points-to-points/2723/12 "2022-03-22T07:23:11Z")

</div>

Thanks Esteban. I never knew about this, and it is a bit _buried_ in the docs. I see that it applies only to modern mode.
