Create a "wet-dry" mask grid from shoreline data base
gmt grdlandmask -Goutgrid -Iincrement -Rregion [ -Amin_area[/min_level/max_level][+a[g|i][s|S]][+l|r][+ppercent] ] [ -Dresolution[+f] ] [ -E[bordervalues] ] [ -Nmaskvalues ] [ -V[level] ] [ -rreg ] [ -x[[-]n] ] [ --PAR=value ]
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.
Give the name of the output mask grid. Optionally, append =ID for writing a specific file format (See full description). The following modifiers are supported:
+d - Divide data values by given divisor [Default is 1].
+n - Replace data values matching invalid with a NaN.
+o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].
+s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].
Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use =gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.
Set the grid spacing as x_inc [and optionally y_inc].
Geographical (degrees) coordinates: Optionally, append an increment unit. Choose among:
m to indicate arc minutes
s to indicate arc seconds
e (meter), f (foot), k (km), M (mile), n (nautical mile) or u (US survey foot), in which case the increment will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to x_inc; otherwise it will be converted to degrees latitude.
All coordinates: The following modifiers are supported:
+e to slightly adjust the max x (east) or y (north) to fit exactly the given increment if needed [Default is to slightly adjust the increment to fit the given domain].
+n to define the number of nodes rather than the increment, in which case the increment is recalculated from the number of nodes, the registration (see GMT File Formats), and the domain. Note: If -Rgrdfile is used then the grid spacing and the registration have already been initialized; use -I and -R to override these values.
Specify the region of interest.
The region may be specified in one of several ways:
-Rwest/east/south/north. This is the standard way to specify geographic regions when using map projections where meridians and parallels are rectilinear. The coordinates may be specified in decimal degrees or in [±]dd:mm[:ss.xxx][W|E|S|N] format.
-Rwest/south/east/north+r. This form is useful for map projections that are oblique, making meridians and parallels poor choices for map boundaries. Here, we instead specify the lower left corner and upper right corner geographic coordinates, followed by the modifier +r. This form guarantees a rectangular map even though lines of equal longitude and latitude are not straight lines.
-Rg or -Rd. These forms can be used to quickly specify the global domain (0/360 for -Rg and -180/+180 for -Rd in longitude, with -90/+90 in latitude).
-Rcode1,code2,…[+e|r|Rincs]. This indirectly supplies the region by consulting the DCW (Digital Chart of the World) database and derives the bounding regions for one or more countries given by the codes. Simply append one or more comma-separated countries using either the two-character ISO 3166-1 alpha-2 convention (e.g., NO) or the full country name (e.g., Norway). To select a state within a country (if available), append .state (e.g, US.TX), or the full state name (e.g., Texas). To specify a whole continent, spell out the full continent name (e.g., -RAfrica). Finally, append any DCW collection abbreviations or full names for the extent of the collection or named region. All names are case-insensitive. The following modifiers can be appended:
+r to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no adjustment]. For example, -RFR+r1 will select the national bounding box of France rounded to nearest integer degree, where inc can be positive to expand the region or negative to shrink the region.
+R to adjust the region by adding the amounts specified by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no extension], where inc can be positive to expand the region or negative to shrink the region.
+e to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc, while ensuring that the bounding box is adjusted by at least 0.25 times the increment [default is no adjustment], where inc can be positive to expand the region or negative to shrink the region.
-Rxmin/xmax/ymin/ymax[+uunit] specifies a region in projected units (e.g., UTM meters) where xmin/xmax/ymin/ymax are Cartesian projected coordinates compatible with the chosen projection (-J) and unit is an allowable distance unit [e]; we inversely project to determine the actual rectangular geographic region. For projected regions centered on (0,0) you may use the short-hand -Rhalfwidth[/halfheight]+uunit, where halfheight defaults to halfwidth if not given. This short-hand requires the +u modifier.
-Rjustifylon0/lat0/nx/ny, where justify is a 2-character combination of L|C|R (for left, center, or right) and T|M|B (for top, middle, or bottom) (e.g., BL for lower left). The two character code justify indicates which point on a rectangular region region the lon0/lat0 coordinates refer to and the grid dimensions nx and ny are used with grid spacings given via -I to create the corresponding region. This method can be used when creating grids. For example, -RCM25/25/50/50 specifies a 50x50 grid centered on 25,25.
-Rgridfile. This will copy the domain settings found for the grid in specified file. Note that depending on the nature of the calling module, this mechanism will also set grid spacing and possibly the grid registration (see Grid registration: The -r option).
-Ra[uto] or -Re[xact]. Under modern mode, and for plotting modules only, you can automatically determine the region from the data used. You can either get the exact area using -Re [Default if no -R is given] or a slightly larger area sensibly rounded outwards to the next multiple of increments that depend on the data range using -Ra.
Features with an area smaller than min_area in km^2 or of hierarchical level that is lower than min_level or higher than max_level will not be plotted [Default is 0/0/4 (all features)]. Level 2 (lakes) contains regular lakes and wide river bodies which we normally include as lakes; append +r to just get river-lakes or +l to just get regular lakes. Append +ppercent to exclude polygons whose percentage area of the corresponding full-resolution feature is less than percent. Use +a to control special aspects of the Antarctica coastline: By default (or add i) we select the ice shelf boundary as the coastline for Antarctica; alternatively, add g to select the ice grounding line instead. For expert users who wish to utilize their own Antarctica (with islands) coastline you can add s to skip all GSHHG features below 60S. In contrast, you can add S to instead skip all features north of 60S. See GSHHG INFORMATION below for more details.
Selects the resolution of the data set to use ((f)ull, (h)igh, (i)ntermediate, (l)ow, or (c)rude). The resolution drops off by ~80% between data sets. [Default is l]. Append +f to automatically select a lower resolution should the one requested not be available [abort if not found]. Alternatively, choose (a)uto to automatically select the best resolution given the chosen region. Note that because the coastlines differ in details a node in a mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected.
Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be inside]. Alternatively, append either the four values cborder/lborder/iborder/pborder or just the single value bordervalue (for the case when they should all be the same value). This turns on the line-tracking mode. Now, after setting the mask values specified via -N we trace the lines and change the node values for all cells traversed by a line to the corresponding border value. Here, cborder is used for cells traversed by the coastline, lborder for cells traversed by a lake outline, iborder for islands-in-lakes outlines, and pborder for ponds-in-islands-in-lakes outlines [Default is no line tracing].
Sets the values that will be assigned to nodes. Values can be any number, including the textstring NaN. Also select -E to let nodes exactly on feature boundaries be considered outside [Default is inside]. Specify this information using 1 of 2 formats:
[Default is 0/1/0/1/0 (i.e., 0/1)].
- -r[g|p] (more …)
Set node registration [gridline].
- -x[[-]n] (more …)
Limit number of cores used in multi-threaded algorithms (OpenMP required).
- -^ or just -
Print a short message about the syntax of the command, then exit (Note: on Windows just use -).
- -+ or just +
Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.
- -? or no arguments
Print a complete usage (help) message, including the explanation of all options, then exit.
Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.
A grid produced by grdlandmask is a categorical dataset. As such, one has to be careful not to interpolate it with standard methods, such as splines. However, if you make a map of this grid using a map projection the grid will be reprojected to yield a rectangular matrix in the projected coordinates. This interpolation is done using splines by default and thus may yield artifacts in your map. We recommend you use grdimage -nn to instead use a nearest neighbor interpolation for such cases.
Global Landmask Grids¶
Before you make your own masks, be aware that the GMT data server offers global landmask files in multiple grid resolutions. These can be accessed using the remote file names @earth_mask_rru[_reg], where rru and the optional reg indicate the resolution and registration that you desire. See Global Earth Mask Grids for more information on the availability of resolutions.
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 three sources: World Vector Shorelines (WVS, not including Antarctica), CIA World Data Bank II (WDBII), and Atlas of the Cryosphere (AC, for Antarctica only). Apart from Antarctica, 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. The Antarctica coastlines come in two flavors: ice-front or grounding line, selectable via the -A option. Much processing has taken place to convert WVS, WDBII, and AC 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 Global Self-consistent, Hierarchical, High-resolution Geography Database (GSHHG) for further details.