(2) Image presentations¶
As our second example we will demonstrate how to make color images from gridded data sets (again, we will defer the actual making of grid files to later examples). We will use grdraster to extract 2-D grid files of bathymetry and Geosat geoid heights and put the two images on the same page. The region of interest is the Hawaiian islands, and due to the oblique trend of the island chain we prefer to rotate our geographical data sets using an oblique Mercator projection defined by the hotspot pole at (68W, 69N). We choose the point (190, 25.5) to be the center of our projection (e.g., the local origin), and we want to image a rectangular region defined by the longitudes and latitudes of the lower left and upper right corner of region. In our case we choose (160, 20) and (220, 30) as the corners. We use grdimage to make the illustration:
#!/bin/bash
# GMT EXAMPLE 02
# $Id$
#
# Purpose: Make two color images based gridded data
# GMT modules: gmtset, grd2cpt, grdimage, makecpt, psscale, pstext
# Unix progs: rm
#
ps=example_02.ps
gmt set FONT_TITLE 30p MAP_ANNOT_OBLIQUE 0
gmt makecpt -Crainbow -T-2/14/2 > g.cpt
gmt grdimage HI_geoid2.nc -R160/20/220/30+r -JOc190/25.5/292/69/4.5i -E50 -K -P \
-B10 -Cg.cpt -X1.5i -Y1.25i > $ps
gmt psscale -Cg.cpt -DJRM+o0.6i/0+e+mc -R -J -O -K -Bx2+lGEOID -By+lm >> $ps
gmt grd2cpt HI_topo2.nc -Crelief -Z > t.cpt
gmt grdimage HI_topo2.nc -I+a0 -R -J -B+t"H@#awaiian@# T@#opo and @#G@#eoid@#" \
-B10 -E50 -O -K -Ct.cpt -Y4.5i --MAP_TITLE_OFFSET=0.5i >> $ps
gmt psscale -Ct.cpt -DJRM+o0.6i/0+mc -R -J -O -K -I0.3 -Bx2+lTOPO -By+lkm >> $ps
gmt pstext -R0/8.5/0/11 -Jx1i -F+f30p,Helvetica-Bold+jCB -O -N -Y-4.5i >> $ps << END
-0.4 7.5 a)
-0.4 3.0 b)
END
rm -f ?.cpt gmt.conf
The first step extracts the 2-D data sets from the local data base using
grdraster that may be adapted to reflect
the nature of your data base format. It automatically figures out the
required extent of the region given the two corners points and the
projection. The extreme meridians and parallels enclosing the oblique
region is -R159:50/220:10/3:10/47:35. This is the area extracted
by grdraster. For your convenience
we have commented out those lines and provided the two extracted files
so you do not need grdraster to try
this example. By using the embedded grid file format mechanism we saved
the topography using kilometers as the data unit. We now have two grid
files with bathymetry and geoid heights, respectively. We use
makecpt to generate a linear color
palette file geoid.cpt
for the geoid and use
grd2cpt to get a histogram-equalized
CPT topo.cpt
for the topography data. To emphasize the structures in the
data we calculate the slopes in the north-south direction using
grdgradient; these will be used to
modulate the color image. Next we run
grdimage to create a color-code image
of the Geosat geoid heights, and draw a color legend to the right of the
image with psscale. Similarly, we run
grdimage but specify -Y4.5i to
plot above the previous image. Adding scale and label the two plots a)
and b) completes the illustration.