# Animation: ship track from NMEA

**URL:** https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758
**Category:** Showcase
**Created:** [March 15, 2023, 11:51am UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758 "2023-03-15T11:51:57Z")
**Posts on this page:** 9
**Page:** 1

<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 15, 2023, 11:51am UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/1 "2023-03-15T11:51:57Z")

</div>

Simple animation script using NMEA (from GPS/GNSS) to plot ship track.

**Q** : I would like to have better annotation along the progress bar; annotated ticks for May {09-13} and small ticks every e.g. 6h with an annotated tick every 12th hour. Tips are welcome!

[![](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/a/a600e8bc949f1a3038f8899e75cd94824cf8c5b7.jpeg "animasjon shiptrack av svalbardtokt") ](https://www.youtube.com/watch?v=-pYUa7TwK4Q)

```auto
#!/usr/bin/env bash

# start preprocessing
# format nmea data to: lon lat yyyy-mm-ddTThhmmss.xx,
# e.g. 010:23.36686 78:39.62868 2009-05-10T030308.60
grep -e GPZDA cruisetrack.TXT | awk -F, '{print $5"-"$4"-"$3"T"$2}' > dato-tid # get date and time
grep -e GPGLL cruisetrack.TXT | awk -F, '{print $4,$2}' | sed -e "s/.\{3\}/&:/" | sed -e "s/.\{15\}/&:/" > lon-lat.txt # get lon and lat

# merge the two files
paste -d' ' lon-lat.txt dato-tid > lon-lat-time

# clean up
rm dato-tid lon-lat.txt
# end preprocessing

# this gives 4981 frames, 83 frames/sec. ~-> 60 sec. animation
start=2009-05-09T204347.13
stop=2009-05-13T073209.16

gmt math --FORMAT_CLOCK_IN=hhmmss.xx -o0 -T${start}/${stop}/1m T = times.txt

cat<<eof > main.sh
gmt begin
gmt set GMT_THEME minimal

gmt coast -Ggray -JS10/90/12c -R8/77.75/18/80r
gmt plot lon-lat-time
gmt events -Sc0.01c -Gred lon-lat-time -T\${MOVIE_COL0} --FORMAT_CLOCK_IN=hhmmss.xx -Bxaf -Byaf

gmt end
eof

gmt movie main.sh -Nanimasjon-shiptrack-av-svalbardtokt -C17cx19cx100 -Fmp4 -Ttimes.txt -V -Z -Pf+jTC+ac0 -Lc0+jBL -D83 --FORMAT_CLOCK_MAP=hh:mm

rm times.txt main.sh lon-lat-time

```

---

<div class="post-metadata">

### Author: ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)
#### Post date: [March 15, 2023, 12:55pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/2 "2023-03-15T12:55:04Z")

</div>

-Bp (primary) and -Bs (secondary) maybe?

---

<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 15, 2023, 1:24pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/3 "2023-03-15T13:24:59Z")

</div>

Ship tracks are usually dealt with via the mgd77 supplement’s **mgd77track**.

---

<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 15, 2023, 1:35pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/4 "2023-03-15T13:35:58Z")

</div>

> [@Andreas](#):
>
> I would like to have better annotation along the progress bar; annotated ticks for May {09-13} and small ticks every e.g. 6h with an annotated tick every 12th hour.

Do you want them only in the progress bar? Or also along the tracks within the map?

---

<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 15, 2023, 1:40pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/5 "2023-03-15T13:40:28Z")

</div>

Thank you all!

@PlanetGus: Aha, will test  
@pwessel: thanks - this was an attempt to do it ‘the easy way’ (which may be the hard way?) Will check out **mgd77track**  
@Esteban82: I was primarily thinking about the progress bar, but now that you mention it, it would be very interesting to have annotations along the tracks within the map as well.

---

<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 15, 2023, 1:47pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/6 "2023-03-15T13:47:28Z")

</div>

You are welcome.

For the tracks, I think you have to follow Paul’s suggestion. I think [mgd77track -L](https://docs.generic-mapping-tools.org/dev/supplements/mgd77/mgd77track.html#l)

---

<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 15, 2023, 2:09pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/7 "2023-03-15T14:09:03Z")

</div>

Thanks for the tips - never used **mgd77track** so need to read up on it.

---

<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 18, 2023, 1:12pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/8 "2023-03-18T13:12:23Z")

</div>

Your best bet would be to awk your track data to the plain tab-separated format (see -Ft in gmt77convert) and save as a _.dat file. That can then be used with the mgd77_ tools.

---

<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 18, 2023, 1:34pm UTC](https://forum.generic-mapping-tools.org/t/animation-ship-track-from-nmea/3758/9 "2023-03-18T13:34:48Z")

</div>

Thanks Paul. Will test.
