grdlandmask - Create a “wet-dry” mask grid from shoreline data base
grdlandmask -Gmask_grd_file] -Ixinc[unit][=|+][/yinc[unit][=|+]] -Rwest/east/south/north[r] [ -Amin_area[/min_level/max_level][+as][+r|l][ppercent] ] [ -Dresolution[+] ] [ -Nmaskvalues[o] ] [ -V[level] ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
grdlandmask reads the selected shoreline database and uses that information to decide which nodes in the specified grid are over land or over water. The nodes defined by the selected region and lattice spacing will be set according to one of two criteria: (1) land vs water, or (2) the more detailed (hierarchical) ocean vs land vs lake vs island vs pond. The resulting mask may be used in subsequent operations involving grdmath to mask out data from land [or water] areas.
Sets the values that will be assigned to nodes. Values can be any number, including the textstring NaN. Append o to let nodes exactly on feature boundaries be considered outside [Default is inside]. Specify this information using 1 of 2 formats:
-Nwet/dry.
-Nocean/land/lake/island/pond.
[Default is 0/1/0/1/0 (i.e., 0/1)].
By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called “packing” of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. See grdreformat and Section Grid file format specifications of the GMT Technical Reference and Cookbook for more information.
When writing a netCDF file, the grid is stored by default with the variable name “z”. To specify another variable name varname, append ?varname to the file name. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes.
To set all nodes on land to NaN, and nodes over water to 1, using the high resolution data set, do
gmt grdlandmask -R-60/-40/-40/-30 -Dh -I5m -N1/NaN -Gland_mask.nc -V
To make a 1x1 degree global grid with the hierarchical levels of the nodes based on the low resolution data:
gmt grdlandmask -R0/360/-90/90 -Dl -I1 -N0/1/2/3/4 -Glevels.nc -V
The coastline database is GSHHG (formerly GSHHS) which is compiled from two sources: World Vector Shorelines (WVS) and CIA World Data Bank II (WDBII). In particular, all level-1 polygons (ocean-land boundary) are derived from the more accurate WVS while all higher level polygons (level 2-4, representing land/lake, lake/island-in-lake, and island-in-lake/lake-in-island-in-lake boundaries) are taken from WDBII. Much processing has taken place to convert WVS and WDBII data into usable form for GMT: assembling closed polygons from line segments, checking for duplicates, and correcting for crossings between polygons. The area of each polygon has been determined so that the user may choose not to draw features smaller than a minimum area (see -A); one may also limit the highest hierarchical level of polygons to be included (4 is the maximum). The 4 lower-resolution databases were derived from the full resolution database using the Douglas-Peucker line-simplification algorithm. The classification of rivers and borders follow that of the WDBII. See the GMT Cookbook and Technical Reference Appendix K for further details.