(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 grdcut to extract 2-D grid files of bathymetry and Geosat geoid heights from global grids 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:
#!/usr/bin/env bash
# GMT EXAMPLE 02
#
# Purpose: Make two color images based gridded data
# GMT modules: set, grd2cpt, grdimage, makecpt, colorbar, subplot
#
gmt begin ex02
gmt set MAP_ANNOT_OBLIQUE 0
gmt subplot begin 2x1 -A+JTL+o0.1i/0 -Fs6i/3.5i -M0 -R160/20/220/30+r -JOc190/25.5/292/69/6i -X1.5i -Y1.5i -B10 -T"H@#awaiian@# T@#opo and @#G@#eoid@#"
gmt subplot set 0,0 -Ce1.1i
gmt grd2cpt @HI_topo_02.nc -Crelief -Z
gmt grdimage @HI_topo_02.nc -I+a0
gmt colorbar -DJRM+o0.6i/0+mc -I0.3 -Bx2+lTOPO -By+lkm
gmt subplot set 1,0 -Ce1.1i
gmt makecpt -Crainbow -T-2/14/2
gmt grdimage @HI_geoid_02.nc
gmt colorbar -DJRM+o0.6i/0+e+mc -Bx2+lGEOID -By+lm
gmt subplot end
gmt end show
The first step extracts the 2-D data sets from the global data grids using
grdcut. Given -J, 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 grdcut. For your convenience
we have commented out those lines and provided the two extracted files
so you do not need to run grdcut 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 colorbar. 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.