1GRDMASK(1) Generic Mapping Tools GRDMASK(1)
2
3
4
6 grdmask - Create mask grid files from xy paths.
7
9 grdmask pathfiles -Gmask_grd_file] -Ixinc[unit][=|+][/yinc[unit][=|+]]
10 -Rwest/east/south/north[r] [ -A[m|p] ] [ -F ] [ -H[i][nrec] ] [
11 -M[flag] ] [ -Nout/edge/in ] [ -Ssearch_radius[m|c|k|K] ] [ -V ] [
12 -:[i|o] ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] [ -fcolinfo ]
13
15 grdmask can operate in two different modes. 1. It reads one or more xy-
16 files that each define a closed polygon. The nodes defined by the
17 specified region and lattice spacing will be set equal to one of three
18 possible values depending on whether the node is outside, on the poly‐
19 gon perimeter, or inside the polygon. The resulting mask may be used
20 in subsequent operations involving grdmath to mask out data from polyg‐
21 onal areas. 2. The xy-files simply represent data point locations and
22 the mask is set to the inside or outside value depending on whether a
23 node is within a maximum distance from the nearest data point. If the
24 distance specified is zero then only the nodes nearest each data point
25 are considered "inside".
26
27 pathfiles
28 The name of 1 or more ASCII [or binary, see -b] files holding
29 the polygon(s) or data points.
30
31 -G Name of resulting output mask grid file. (See GRID FILE FORMATS
32 below).
33
34 -I x_inc [and optionally y_inc] is the grid spacing. Optionally,
35 append a suffix modifier. Geographical (degrees) coordinates:
36 Append m to indicate arc minutes or c to indicate arc seconds.
37 If one of the units e, k, i, or n is appended instead, the
38 increment is assumed to be given in meter, km, miles, or nauti‐
39 cal miles, respectively, and will be converted to the equivalent
40 degrees longitude at the middle latitude of the region (the con‐
41 version depends on ELLIPSOID). If /y_inc is given but set to 0
42 it will be reset equal to x_inc; otherwise it will be converted
43 to degrees latitude. All coordinates: If = is appended then the
44 corresponding max x (east) or y (north) may be slightly adjusted
45 to fit exactly the given increment [by default the increment may
46 be adjusted slightly to fit the given domain]. Finally, instead
47 of giving an increment you may specify the number of nodes
48 desired by appending + to the supplied integer argument; the
49 increment is then recalculated from the number of nodes and the
50 domain. The resulting increment value depends on whether you
51 have selected a gridline-registered or pixel-registered grid;
52 see Appendix B for details.
53
54 -R xmin, xmax, ymin, and ymax specify the Region of interest. For
55 geographic regions, these limits correspond to west, east,
56 south, and north and you may specify them in decimal degrees or
57 in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left
58 and upper right map coordinates are given instead of w/e/s/n.
59 The two shorthands -Rg and -Rd stand for global domain (0/360
60 and -180/+180 in longitude respectively, with -90/+90 in lati‐
61 tude). For calendar time coordinates you may either give (a)
62 relative time (relative to the selected TIME_EPOCH and in the
63 selected TIME_UNIT; append t to -JX|x), or (b) absolute time of
64 the form [date]T[clock] (append T to -JX|x). At least one of
65 date and clock must be present; the T is always required. The
66 date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian
67 calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
68 string must be of the form hh:mm:ss[.xxx]. The use of delim‐
69 iters and their type and positions must be exactly as indicated
70 (however, input, output and plot formats are customizable; see
71 gmtdefaults).
72
74 -A If the input data are geographic (as indicated by -fi) then the
75 sides in the polygons will be approximated by great circle arcs.
76 When using the -A sides will be regarded as straight lines.
77 Alternatively, append m to have sides first follow meridians,
78 then parallels. Or append p to first follow parallels, then
79 meridians.
80
81 -F Force pixel node registration [Default is gridline registra‐
82 tion]. (Node registrations are defined in GMT Cookbook Appendix
83 B on grid file formats.)
84
85 -H Input file(s) has Header record(s). Number of header records
86 can be changed by editing your .gmtdefaults4 file. If used, GMT
87 default is 1 header record. Use -Hi if only input data should
88 have header records [Default will write out header records if
89 the input data have them]. Blank lines and lines starting with #
90 are always skipped.
91
92 -M Multiple segment file. Segments are separated by a record whose
93 first character is flag. [Default is '>'].
94
95 -N Sets the values that will be assigned to nodes that are outside
96 the polygons, on the edge, or inside. Values can be any number,
97 including the textstring NaN [Default is 0/0/1].
98
99 -S Set nodes depending on their distance from the nearest data
100 point. Nodes within radius [0] from a data point are considered
101 inside. Append m to indicate minutes or c to indicate seconds.
102 Append k to indicate km (implies -R and -I are in degrees, and
103 we will use a fast flat Earth approximation to calculate dis‐
104 tance). For more accuracy, use uppercase K if distances should
105 be calculated along geodesics. However, if the current ELLIP‐
106 SOID is set to Sphere then spherical great circle calculations
107 are used.
108
109 -V Selects verbose mode, which will send progress reports to stderr
110 [Default runs "silently"].
111
112 -bi Selects binary input. Append s for single precision [Default is
113 d (double)]. Uppercase S or D will force byte-swapping.
114 Optionally, append ncol, the number of columns in your binary
115 input file if it exceeds the columns needed by the program. Or
116 append c if the input file is netCDF. Optionally, append
117 var1/var2/... to specify the variables to be read. [Default is
118 2 input columns].
119
120 -f Special formatting of input and/or output columns (time or geo‐
121 graphical data). Specify i or o to make this apply only to
122 input or output [Default applies to both]. Give one or more
123 columns (or column ranges) separated by commas. Append T (abso‐
124 lute calendar time), t (relative time in chosen TIME_UNIT since
125 TIME_EPOCH), x (longitude), y (latitude), or f (floating point)
126 to each column or column range item. Shorthand -f[i|o]g means
127 -f[i|o]0x,1y (geographic coordinates).
128
130 By default GMT writes out grid as single precision floats in a COARDS-
131 complaint netCDF file format. However, GMT is able to produce grid
132 files in many other commonly used grid file formats and also facili‐
133 tates so called "packing" of grids, writing out floating point data as
134 2- or 4-byte integers. To specify the precision, scale and offset, the
135 user should add the suffix =id[/scale/offset[/nan]], where id is a two-
136 letter identifier of the grid type and precision, and scale and offset
137 are optional scale factor and offset to be applied to all grid values,
138 and nan is the value used to indicate missing data. See grdreformat(1)
139 and Section 4.17 of the GMT Technical Reference and Cookbook for more
140 information.
141
142 When writing a netCDF file, the grid is stored by default with the
143 variable name "z". To specify another variable name varname, append
144 ?varname to the file name. Note that you may need to escape the spe‐
145 cial meaning of ? in your shell program by putting a backslash in front
146 of it, or by placing the filename and suffix between quotes or double
147 quotes.
148
150 When the output grid type is netCDF, the coordinates will be labeled
151 "longitude", "latitude", or "time" based on the attributes of the input
152 data or grid (if any) or on the -f or -R options. For example, both
153 -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid.
154 When the x, y, or z coordinate is time, it will be stored in the grid
155 as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH
156 in the .gmtdefaults file or on the command line. In addition, the unit
157 attribute of the time variable will indicate both this unit and epoch.
158
160 To set all nodes inside and on the polygons coastline_*.xy to 0, and
161 outside points to 1, do
162
163 grdmask coastline_*.xy -R-60/-40/-40/-30 -I5m -N1/0/0 -Gland_mask.grd
164 -V
165
166 To set nodes within 50 km of data points to 1 and other nodes to NaN,
167 do
168
169 grdmask data.xyz -R-60/-40/-40/-30 -I5m -NNaN/1/1 -S50k -Gdata_mask.grd
170 -V
171
173 GMT(1), grdlandmask(1), grdmath(1), grdclip(1), psmask(1), psclip(1)
174
175
176
177GMT 4.3.1 15 May 2008 GRDMASK(1)