(2) Examining DEMs using variable illumination — GMT 5.1.1 documentation

### Navigation

- index
- next
- previous
- Project Home »
- GMT 5.1.1 documentation »
- The GMT historical collection »
- Search:

# (2) Examining DEMs using variable illumination

Our next animation uses a gridded topography for parts of Colorado (US); the file is distributed with the tutorial examples. Here, we want to use grdimage to generate a shaded-relief image sequence in which we sweep the illumination azimuth around the entire horizon. The resulting animation illustrates how changing the illumination azimuth can bring out subtle features (or artifacts) in the gridded data. The red arrow points in the direction of the illumination.

    #!/bin/bash
    #               GMT ANIMATION 02
    #
    # Purpose:      Make web page with simple animated GIF of a DEM grid
    # GMT progs:    gmt gmtset, gmt gmtmath, gmt grdgradient, gmt makecpt, gmt grdimage gmt psxy, gmt ps2raster
    # Unix progs:   awk, mkdir, rm, mv, echo, convert, cat
    # Note:         Run with any argument to build movie; otherwise 1st frame is plotted only.
    #
    # 1. Initialization
    # 1a) Assign movie parameters
    width=3.5i
    height=4.15i
    dpi=72
    n_frames=36
    name=anim_02
    ps=.ps
    # 1b) setup
    del_angle=`gmt gmtmath -Q 360  DIV =`
    gmt makecpt -Crainbow -T500/4500/5000 -Z > $$.cpt
    # 2. Main loop
    mkdir -p $$
    frame=0
    while [  -lt  ]; do
    	# Create file name using a name_##.tif format
    	file=`gmt_set_framename  `
    	angle=`gmt gmtmath -Q   MUL =`
    	dir=`gmt gmtmath -Q  180 ADD =`
    	gmt grdgradient us.nc -A -Nt2 -fg -G$$.us_int.nc
    	gmt grdimage us.nc -I$$.us_int.nc -JM3i -P -K -C$$.cpt -BWSne -B1 -X0.35i -Y0.3i \
    	--PS_MEDIA=x --FONT_ANNOT_PRIMARY=9p > $$.ps
    	gmt psxy -Rus.nc -J -O -K -Sc0.8i -Gwhite -Wthin >> $$.ps <<< "256.25 35.6"
    	gmt psxy -Rus.nc -J -O -Sv0.1i+e -Gred -Wthick >> $$.ps <<< "256.25 35.6  0.37"
    	if [ $# -eq 0 ]; then
    		mv $$.ps
    		gmt_cleanup .gmt
    		gmt_abort ": First frame plotted to .ps"
    	fi
    #	RIP to TIFF at specified dpi
    	gmt ps2raster -E -Tt $$.ps
    	mv -f $$.tif $$/.tif
    	echo "Frame  completed"
    	frame=`gmt_set_framenext `
    done
    # 3. Create animated GIF file and HTML for web page
    convert -delay 10 -loop 0 $$/*.tif .gif
    cat << END > .html
    <HTML>
    <TITLE>GMT shading: A tool for feature detection</TITLE>
    <BODY bgcolor="#ffffff">
    <CENTER>
    <H1>GMT shading: A tool for feature detection</H1>
    <IMG src=".gif">
    </CENTER>
    <HR>
    We make illuminated images of topography from a section of Colorado and
    vary the azimuth of the illumination (see arrow).  As the light-source sweeps around
    the area over 360 degrees we notice that different features in the data
    become hightlighted.  This is because the illumination is based on data
    gradients and such derivatives will high-light short-wavelength signal.
    Again, our animation uses Imagemagick's convert tool to make an animated GIF file
    with a 0.1 second pause between the 36 frames.
    <HR>
    <I>.sh: Created by  on `date`</I>
    </BODY>
    </HTML>
    END
    # 4. Clean up temporary files
    gmt_cleanup .gmt

As you can see, these sorts of animations are not terribly difficult to put together, especially since our vantage point is fixed. In the next example we will move the “camera” around and must therefore deal with how to frame perspective views.

Animation of a DEM using variable illumination.

### Navigation

- index
- next
- previous
- Project Home »
- GMT 5.1.1 documentation »
- The GMT historical collection »
- Search: