(12) Optimal triangulation of data

Our next example operates on a data set of topographic readings non-uniformly distributed in the plane (Table 5.11 in Davis: Statistics and Data Analysis in Geology, J. Wiley). We use triangulate to perform the optimal Delaunay triangulation, then use the output to draw the resulting network. We label the node numbers as well as the node values, and call pscontour to make a contour map and image directly from the raw data. Thus, in this example we do not actually make grid files but still are able to contour and image the data. We use the CPT topo.cpt (created via gmtinfo and makecpt). The script becomes:

#!/bin/bash
#		GMT EXAMPLE 12
#		$Id$
#
# Purpose:	Illustrates Delaunay triangulation of points, and contouring
# GMT modules:	makecpt, gmtinfo, pscontour, pstext, psxy, triangulate
# Unix progs:	echo, rm
#
# First draw network and label the nodes
#
ps=example_12.ps
gmt triangulate table_5.11 -M > net.xy
gmt psxy -R0/6.5/-0.2/6.5 -JX3.06i/3.15i -B2f1 -BWSNe net.xy -Wthinner -P -K -X0.9i -Y4.65i > $ps
gmt psxy table_5.11 -R -J -O -K -Sc0.12i -Gwhite -Wthinnest >> $ps
gmt pstext table_5.11 -R -J -F+f6p+r -O -K >> $ps
#
# Then draw network and print the node values
#
gmt psxy -R -J -B2f1 -BeSNw net.xy -Wthinner -O -K -X3.25i >> $ps
gmt psxy -R -J -O -K table_5.11 -Sc0.03i -Gblack >> $ps
gmt pstext table_5.11 -R -J -F+f6p+jLM -O -K -Gwhite -W -C0.01i -D0.08i/0i -N >> $ps
#
# Then contour the data and draw triangles using dashed pen; use "gmt gmtinfo" and "gmt makecpt" to make a
# color palette (.cpt) file
#
T=`gmt info -T25+c2 table_5.11`
gmt makecpt -Cjet $T > topo.cpt
gmt pscontour -R -J table_5.11 -B2f1 -BWSne -Wthin -Ctopo.cpt -Lthinnest,- -Gd1i -X-3.25i -Y-3.65i \
	-O -K >> $ps
#
# Finally color the topography
#
gmt pscontour -R -J table_5.11 -B2f1 -BeSnw -Ctopo.cpt -I -X3.25i -O -K >> $ps
echo "3.16 8 Delaunay Triangulation" | \
	gmt pstext -R0/8/0/11 -Jx1i -F+f30p,Helvetica-Bold+jCB -O -X-3.25i >> $ps
#
rm -f net.xy topo.cpt
../_images/example_12.png

Optimal triangulation of data.