1GRDMASK(1)                   Generic Mapping Tools                  GRDMASK(1)
2
3
4

NAME

6       grdmask - Create mask grid files from xy paths.
7

SYNOPSIS

9       grdmask  pathfiles -Gmask_grd_file] -Ixinc[unit][=|+][/yinc[unit][=|+]]
10       -Rwest/east/south/north[r] [ -A[m|p]  ]  [  -F  ]  [  -H[i][nrec]  ]  [
11       -Nout/edge/in  ]  [  -Ssearch_radius[m|c|k|K]  ]  [  -V ] [ -:[i|o] ] [
12       -bi[s|S|d|D[ncol]|c[var1/...]] ] [ -fcolinfo ] [ -m[flag] ]
13

DESCRIPTION

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.  Note: if  -Rgrdfile  is  used  then
53              grid  spacing  has  already been initialized; use -I to override
54              the values.
55
56       -R     xmin, xmax, ymin, and ymax specify the Region of interest.   For
57              geographic  regions,  these  limits  correspond  to  west, east,
58              south, and north and you may specify them in decimal degrees  or
59              in  [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left
60              and upper right map coordinates are given  instead  of  w/e/s/n.
61              The  two  shorthands  -Rg and -Rd stand for global domain (0/360
62              and -180/+180 in longitude respectively, with -90/+90  in  lati‐
63              tude).  Alternatively, specify the name of an existing grid file
64              and the -R settings (and grid spacing, if applicable) are copied
65              from  the  grid.   For  calendar time coordinates you may either
66              give (a) relative time (relative to the selected TIME_EPOCH  and
67              in  the  selected TIME_UNIT; append t to -JX|x), or (b) absolute
68              time of the form [date]T[clock] (append T to -JX|x).   At  least
69              one of date and clock must be present; the T is always required.
70              The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian
71              calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
72              string must be of the form hh:mm:ss[.xxx].  The  use  of  delim‐
73              iters  and their type and positions must be exactly as indicated
74              (however, input, output and plot formats are  customizable;  see
75              gmtdefaults).
76

OPTIONS

78       -A     If  the input data are geographic (as indicated by -fi) then the
79              sides in the polygons will be approximated by great circle arcs.
80              When  using  the  -A  sides  will be regarded as straight lines.
81              Alternatively, append m to have sides  first  follow  meridians,
82              then  parallels.  Or  append  p  to first follow parallels, then
83              meridians.
84
85       -F     Force pixel node registration  [Default  is  gridline  registra‐
86              tion].  (Node registrations are defined in GMT Cookbook Appendix
87              B on grid file formats.)
88
89       -H     Input file(s) has header record(s).  If used, the default number
90              of  header records is N_HEADER_RECS.  Use -Hi if only input data
91              should have  header  records  [Default  will  write  out  header
92              records  if  the  input  data  have them]. Blank lines and lines
93              starting with # are always skipped.
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 spherical then great circle calculations are used.
107
108       -V     Selects verbose mode, which will send progress reports to stderr
109              [Default runs "silently"].
110
111       -bi    Selects binary input.  Append s for single precision [Default is
112              d  (double)].   Uppercase  S  or  D  will  force  byte-swapping.
113              Optionally, append ncol, the number of columns  in  your  binary
114              input  file if it exceeds the columns needed by the program.  Or
115              append c  if  the  input  file  is  netCDF.  Optionally,  append
116              var1/var2/...  to specify the variables to be read.  [Default is
117              2 input columns].
118
119       -f     Special formatting of input and/or output columns (time or  geo‐
120              graphical  data).   Specify  i  or  o to make this apply only to
121              input or output [Default applies to both].   Give  one  or  more
122              columns (or column ranges) separated by commas.  Append T (abso‐
123              lute calendar time), t (relative time in chosen TIME_UNIT  since
124              TIME_EPOCH),  x (longitude), y (latitude), or f (floating point)
125              to each column or column range item.  Shorthand  -f[i|o]g  means
126              -f[i|o]0x,1y (geographic coordinates).
127
128       -m     Multiple segment file.  Segments are separated by a record whose
129              first character is flag.  [Default is '>'].
130

GRID FILE FORMATS

132       By default GMT writes out grid as single precision floats in a  COARDS-
133       complaint  netCDF  file  format.   However, GMT is able to produce grid
134       files in many other commonly used grid file formats  and  also  facili‐
135       tates  so called "packing" of grids, writing out floating point data as
136       2- or 4-byte integers. To specify the precision, scale and offset,  the
137       user should add the suffix =id[/scale/offset[/nan]], where id is a two-
138       letter identifier of the grid type and precision, and scale and  offset
139       are  optional scale factor and offset to be applied to all grid values,
140       and nan is the value used to indicate missing data.  See grdreformat(1)
141       and  Section  4.17 of the GMT Technical Reference and Cookbook for more
142       information.
143
144       When writing a netCDF file, the grid is  stored  by  default  with  the
145       variable  name  "z".  To  specify another variable name varname, append
146       ?varname to the file name.  Note that you may need to escape  the  spe‐
147       cial meaning of ? in your shell program by putting a backslash in front
148       of it, or by placing the filename and suffix between quotes  or  double
149       quotes.
150

GEOGRAPHICAL AND TIME COORDINATES

152       When  the  output  grid type is netCDF, the coordinates will be labeled
153       "longitude", "latitude", or "time" based on the attributes of the input
154       data  or  grid  (if  any) or on the -f or -R options. For example, both
155       -f0x -f1t and -R90w/90e/0t/3t will result  in  a  longitude/time  grid.
156       When  the  x, y, or z coordinate is time, it will be stored in the grid
157       as relative time since epoch as specified by TIME_UNIT  and  TIME_EPOCH
158       in the .gmtdefaults file or on the command line.  In addition, the unit
159       attribute of the time variable will indicate both this unit and epoch.
160

EXAMPLES

162       To set all nodes inside and on the polygons coastline_*.xy  to  0,  and
163       outside points to 1, do
164
165       grdmask  coastline_*.xy  -R-60/-40/-40/-30 -I5m -N1/0/0 -Gland_mask.grd
166       -V
167
168       To set nodes within 50 km of data points to 1 and other nodes  to  NaN,
169       do
170
171       grdmask data.xyz -R-60/-40/-40/-30 -I5m -NNaN/1/1 -S50k -Gdata_mask.grd
172       -V
173

SEE ALSO

175       GMT(1), grdlandmask(1), grdmath(1), grdclip(1), psmask(1), psclip(1)
176
177
178
179GMT 4.5.6                         10 Mar 2011                       GRDMASK(1)
Impressum