Next: 3.3 Exercises Up: 3.2 Gridding of arbitrarily Previous: 3.2.2 Gridding with Splines Contents Index

## 3.2.3 Preprocessing

The surface program assumes that the data have been preprocessed to eliminate aliasing, hence we must ensure that this step is completed prior to gridding. GMT comes with three preprocessors, called blockmean, blockmedian, and blockmode. The first averages values inside the grid-spacing boxes, the second returns median values, wile the latter returns modal values. As a rule of thumb, we use means for most smooth data (such as potential fields) and medians (or modes) for rough, non-Gaussian data (such as topography). In addition to the required -R and -I switches, these preprocessors all take the same options (listed in Table 3.4).

Table 3.4: Some of the preprocessing options.

Option | Purpose
-N | Choose pixel registration [Default is gridline]
-W[i o] | Append i or o to read or write weights in the 4th column

With respect to our ship data we preprocess it using the median method:

    blockmedian -R245/255/20/30 -I5m -V ship.xyz >! ship_5m.xyz

The output data can now be used with surface:

    surface ship_5m.xyz -R245/255/20/30 -I5m -Gship.nc -V

If you rerun grdcontour on the new grid file (try it!) you will notice a big difference compared to the grid made by nearneighbor: since surface is a global method it will evaluate the solution at all nodes, even if there are no data constraints. There are numerous options available to us at this point:

1. We can reset all nodes too far from a data constraint to the NaN value.

2. We can pour white paint over those regions where contours are unreliable.

3. We can plot the landmass which will cover most (but not all) of the unconstrained areas.

4. We can set up a clip path so that only the contours in the constrained region will show.

Here we have only time to explore the latter approach. The psmask program can read the same preprocessed data and set up a contour mask based on the data distribution. Once the clip path is activated we can contour the final grid; we finally deactivate the clipping with a second call to psmask. Here's the recipe:

    psmask -R245/255/20/30 -I5m ship_5m.xyz -JM6i -B2 -P -K -V >! map.ps
    grdcontour ship.nc -J -O -K -C250 -A1000 >> map.ps
    psmask -C -O >> map.ps

Next: 3.3 Exercises Up: 3.2 Gridding of arbitrarily Previous: 3.2.2 Gridding with Splines Contents Index