(4) Flying over topography

Our next animation simulates what an imaginary satellite might see as it passes in a great circle from New York to Miami at an altitude of 160 km. We use the general perspective view projection with grdimage and use project to create a great circle path between the two cities, sampled every 5 km. The main part of the script will make the DVD-quality frames from different view points, draw the path on the ground, and add frame numbers to each frame. As this animation generates 355 frames we can use 3rd party tools to turn the image sequence into a MPEG-4 movie. Note: At the moment, grdview cannot use general perspective view projection to allow “fly-through” animations like Fledermaus; we expect to add this functionality in a future version.

#!/usr/bin/env bash
#               GMT ANIMATION 04
#
# Purpose:      Make custom 480p movie of NY to Miami flight
# GMT modules:  set, grdgradient, grdimage, makecpt, project, plot, movie
# Unix progs:   cat
# Note:         Run with any argument to build movie; otherwise 1st frame is plotted as PS only.

if [ $# -eq 0 ]; then	# Just make master PostScript frame 0
	opt="-Mps -Fnone"
else	# Make movie in MP4 format and a thumbnail animated GIF using every 10th frame
	opt="-Fmp4 -A+l+s10"
fi
# 1. Create files needed in the loop
cat << EOF > pre.sh
# Set up flight path
gmt begin
	gmt project -C-73.8333/40.75 -E-80.133/25.75 -G10 -Q > flight_path.txt
	gmt grdcut @earth_relief_02m -R-100/-70/10/50 -GUSEast_Coast.nc
	gmt grdgradient USEast_Coast.nc -A90 -Nt1 -Gint_US.nc
	gmt makecpt -Cglobe -H > globe_US.cpt
gmt end
EOF
# 2. Set up the main frame script
cat << EOF > main.sh
gmt begin
	gmt grdimage -JG\${MOVIE_COL0}/\${MOVIE_COL1}/160/210/55/0/36/34/\${MOVIE_WIDTH}+du \
		-Rg USEast_Coast.nc -Iint_US.nc -Cglobe_US.cpt -X0 -Y0
	gmt plot -W1p flight_path.txt
gmt end
EOF
# 3. Run the movie
gmt movie main.sh -C7.2ix4.8ix100 -Nanim04 -Tflight_path.txt -Sbpre.sh -Zs -H2 -Lf+o0.1i+f14p,Helvetica-Bold $opt
../_images/anim04.png

Flying over topography.