Animation: ship track from NMEA

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!

#!/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
1 Like

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

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

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

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.

You are welcome.

For the tracks, I think you have to follow Paul’s suggestion. I think mgd77track -L

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

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.

Thanks Paul. Will test.