Next: 7.28 Mixing UTM and Up: 7. Creating GMT Graphics Previous: 7.26 General vertical perspective Contents Index

#
7.27 Plotting Sandwell/Smith Mercator img grids

Next, we show how to plot a data grid that is distributed in projected form. The gravity and predicted bathymetry grids produced by David Sandwell and Walter H. F. Smith are not geographical grids but instead given on a spherical Mercator grid. The GMT supplement imgsrc has tools to extract subsets of these large grids. If you need to make a non-Mercator map then you must extract a geographic grid using img2grd and then plot it using your desired map projection. However, if you want to make a Mercator map then you can save time and preserve data quality by avoiding to re-project the data set twice since it is already in a Mercator projection. This example shows how this is accomplished. We use the -M option in img2grd 7.6 to pull out the grid in Mercator units (i.e., do not invert the Mercator projection) and then simply plot the grid using a linear projection with a suitable scale (here 0.25 inches per degrees of longitude). To overlay basemaps and features that has geographic longitude/latitude coordinates we must remember two key issues:

1. This is a spherical Mercator grid so we must use -ELLIPSOID=Sphere with all commands that involve projections (or use gmtset to change the setting).
2. Select Mercator projection and use the same scale that was used with the linear projection.

    #!/bin/sh
    #               GMT EXAMPLE 27
    #
    # Purpose:      Illustrates how to plot Mercator img grids
    # GMT progs:    makecpt, grdgradient, grdimage, grdinfo, pscoast
    # GMT supplement: img2grd (to read Sandwell/Smith img files)
    # Unix progs:   rm, grep, $AWK
    #
    ps=example_27.ps

    # First extract a chunk of faa and retain short int precision to
    # save disk space.  Gravity is thus in 0.1 mGal increments.
    # Next get gradients.  The grid's region is in Mercator x/y units

    #img2grd grav.15.2.img -R145/170/-50/-25 -M -C -T1 -Gtasman_grav.nc=ns
    grdgradient tasman_grav.nc -Nt1 -A45 -Gtasman_grav_i.nc

    # Make a suitable cpt file for mGal

    makecpt -T-120/120/10 -Z -Crainbow > grav.cpt

    # Since this is a Mercator grid we use a linear projection

    grdimage tasman_grav.nc=ns/0.1 -Itasman_grav_i.nc -Jx0.25i -Cgrav.cpt -P -K \
            -U"Example 27 in Cookbook" > $ps

    # Then use pscoast to plot land; get original -R from grid remark
    # and use Mercator projection with same scale as above on a spherical Earth

    R=`grdinfo tasman_grav.nc | grep Remark | awk '{print $NF}'`

    pscoast $R -Jm0.25i -Ba10f5WSne -O -K -Gblack --ELLIPSOID=Sphere \
            -Cwhite -Dh+ --PLOT_DEGREE_FORMAT=dddF >> $ps

    # Put a color legend on top of the land mask justified with 147E,31S

    echo 147E 31S | mapproject -R -J --ELLIPSOID=Sphere > tmp
    echo 147E 31S 1 2.5 | psxy -R -J -O -K -Sr -D0.25i/0.05i -Gwhite -W1p --ELLIPSOID=Sphere --MEASURE_UNIT=inch >> $ps
    pos=`$AWK '{printf "%si/%si\n", $1, $2}' tmp`
    psscale -D$pos/2i/0.15i -Cgrav.cpt -B50f10/:mGal: -I -O >> $ps

    # Clean up

    rm -f grav.cpt *_i.nc .gmt* tmp

This map of the Tasman Sea shows the marine gravity anomalies with land painted black. A color scale bar was then added to complete the illustration.

Figure 7.27: Plotting Sandwell/Smith Mercator img grids.

Next: 7.28 Mixing UTM and Up: 7. Creating GMT Graphics Previous: 7.26 General vertical perspective Contents Index