Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

grdmask.rst 7.6 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  1. .. index:: ! grdmask
  2. .. include:: module_core_purpose.rst_
  3. *******
  4. grdmask
  5. *******
  6. |grdmask_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt grdmask** *pathfiles* |-G|\ *mask_grd_file*
  11. |SYN_OPT-I|
  12. |SYN_OPT-R|
  13. [ |-A|\ [**m**\|\ **p**\|\ **x**\|\ **y**] ]
  14. [ |-N|\ [**z**\|\ **Z**\|\ **p**\|\ **P**]\ *values* ]
  15. [ |-S|\ *search\_radius*\|\ *xlim*\ /*ylim* ] [ |SYN_OPT-V| ]
  16. [ |SYN_OPT-bi| ]
  17. [ |SYN_OPT-di| ]
  18. [ |SYN_OPT-e| ]
  19. [ |SYN_OPT-f| ]
  20. [ |SYN_OPT-g| ]
  21. [ |SYN_OPT-h| ]
  22. [ |SYN_OPT-i| ]
  23. [ |SYN_OPT-j| ]
  24. [ |SYN_OPT-n| ]
  25. [ |SYN_OPT-qi| ]
  26. [ |SYN_OPT-r| ]
  27. [ |SYN_OPT-x| ]
  28. [ |SYN_OPT-:| ]
  29. [ |SYN_OPT--| ]
  30. |No-spaces|
  31. Description
  32. -----------
  33. **grdmask** can operate in two different modes. 1. It reads one or more
  34. *pathfiles* that each define a closed polygon. The nodes defined by the
  35. specified region and lattice spacing will be set equal to one of three
  36. possible values depending on whether the node is outside, on the polygon
  37. perimeter, or inside the polygon. The resulting mask may be used in
  38. subsequent operations involving :doc:`grdmath` to mask out data from
  39. polygonal areas. 2. The *pathfiles* simply represent data point locations
  40. and the mask is set to the inside or outside value depending on whether
  41. a node is within a maximum distance from the nearest data point. If the
  42. distance specified is zero then only the nodes nearest each data point
  43. are considered "inside".
  44. Required Arguments
  45. ------------------
  46. *pathfiles*
  47. The name of 1 or more ASCII [or binary, see
  48. **-bi**] files holding the polygon(s) or data points.
  49. .. _-G:
  50. **-G**\ *mask_grd_file*
  51. Name of resulting output mask grid file. (See GRID FILE FORMATS below).
  52. .. _-I:
  53. .. include:: explain_-I.rst_
  54. .. _-R:
  55. .. |Add_-R| unicode:: 0x20 .. just an invisible code
  56. .. include:: explain_-R.rst_
  57. Optional Arguments
  58. ------------------
  59. .. _-A:
  60. **-A**\ [**m**\|\ **p**\|\ **x**\|\ **y**]
  61. If the input data are geographic (as indicated by **-f**) then the
  62. sides in the polygons will be approximated by great circle arcs.
  63. When using the **-A** sides will be regarded as straight lines.
  64. Alternatively, append **m** to have sides first follow meridians,
  65. then parallels. Or append **p** to first follow parallels, then meridians.
  66. For Cartesian data, points are simply connected, unless you append
  67. **x** or **y** to construct stair-case paths whose first move is along
  68. *x* or *y*, respectively.
  69. .. _-N:
  70. **-N**\ [**z**\|\ **Z**\|\ **p**\|\ **P**]\ *values*
  71. Sets the *out/edge/in* that will be assigned to nodes that are
  72. *out*\ side the polygons, on the *edge*, or *in*\ side. Values can
  73. be any number, including the textstring NaN [Default is 0/0/1].
  74. Optionally, use **Nz** to set polygon insides to the z-value
  75. obtained from the data (either segment header **-Z**\ *zval*,
  76. **-L**\ *header* or via **-a**\ Z=\ *name*); use **-NZ** to consider
  77. the polygon boundary as part of the inside. Alternatively, use
  78. **-Np** to use a running number as polygon ID; optionally append
  79. start of the sequence [0]. Here, **-NP** includes the polygon
  80. perimeter as inside. **Note**:
  81. **-N**\ **z**\|\ **Z**\|\ **p**\|\ **P** cannot be used in
  82. conjunction with **-S**; they also all optionally accept /*out* [0].
  83. .. _-S:
  84. **-S**\ *search\_radius*\|\ *xlim*\ /*ylim*
  85. Set nodes to inside, on edge, or outside depending on their distance
  86. to the nearest data point. Nodes within *radius* [0] from the
  87. nearest data point are considered inside; append a distance unit
  88. (see `Units`_). If *radius* is given as **z** then we instead read
  89. individual radii from the 3rd input column. Unless Cartesian data,
  90. specify the unit of these radii by appending it after **-Sz**.
  91. If **-S** is not set then we consider the input data to define
  92. one or more closed polygon(s) instead. For Cartesian data with
  93. different units you can instead append *xlim*\ /*ylim* which will
  94. perform a rectangular search where all nodes within ±\ *xlim* and
  95. ±\ *ylim* of a data point will be considered inside.
  96. One can also achieve the rectangular selection effect by using the **-S**\ *n_cells*\ **c** form.
  97. Here *n_cells* means the number of cells around each data point. As an example, **-S**\ 0\ **c** means
  98. that only the cell where point lies is masked, **-S**\ 1\ **c** masks one cell beyond that
  99. (i.e. makes a 3x3 neighborhood), and so on.
  100. .. _-V:
  101. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  102. .. include:: explain_-V.rst_
  103. .. |Add_-bi| replace:: [Default is 2 input columns (3 with **-Sz**)].
  104. .. include:: explain_-bi.rst_
  105. .. |Add_-di| unicode:: 0x20 .. just an invisible code
  106. .. include:: explain_-di.rst_
  107. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  108. .. include:: explain_-e.rst_
  109. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  110. .. include:: explain_-f.rst_
  111. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  112. .. include:: explain_-g.rst_
  113. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  114. .. include:: explain_-h.rst_
  115. .. include:: explain_-icols.rst_
  116. .. include:: explain_-qi.rst_
  117. .. include:: explain_distcalc.rst_
  118. **-n**\ [**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+t**\ *threshold*]
  119. Append **+b**\ *BC* to set any boundary conditions to be used,
  120. adding **g** for geographic, **p** for periodic, or **n** for
  121. natural boundary conditions. For the latter two you may append **x**
  122. or **y** to specify just one direction, otherwise both are assumed.
  123. [Default is geographic if grid is geographic].
  124. .. |Add_nodereg| unicode:: 0x20 .. just an invisible code
  125. .. include:: explain_nodereg.rst_
  126. .. include:: explain_core.rst_
  127. .. include:: explain_help.rst_
  128. .. include:: explain_distunits.rst_
  129. .. include:: explain_grd_output.rst_
  130. .. include:: explain_grd_coord.rst_
  131. .. include:: explain_inside.rst_
  132. Notes
  133. -----
  134. A grid produced by grdmask is a *categorical* dataset. As such,
  135. one has to be careful not to interpolate it with standard methods,
  136. such as splines. However, if you make a map of this grid using
  137. a map projection the grid will be reprojected to yield a rectangular
  138. matrix in the projected coordinates. This interpolation is done
  139. using splines by default and thus may yield artifacts in your map.
  140. We recommend you use :doc:`grdimage` **-nn** to instead use a nearest
  141. neighbor interpolation for such cases.
  142. Save storage space
  143. ------------------
  144. Since most uses of grdmask revolves around creating mask grids that hold just a few integer
  145. values (and perhaps NaN), we choose to write them to disk as byte grids by appending the
  146. suffix **=nb** to the desired grid filename. Some situations may store integers that exceed
  147. the range available in a byte and for those we specify a short integer grid with **=ns**.
  148. For larger integers you may consider **=ni**, otherwise use the default float grid format.
  149. Examples
  150. --------
  151. .. include:: explain_example.rst_
  152. To set all nodes inside and on the polygons coastline_*.xy to 0, and
  153. outside points to 1, do
  154. ::
  155. gmt grdmask coastline_*.xy -R-60/-40/-40/-30 -I5m -N1/0/0 -Gland_mask.nc=nb -V
  156. To set nodes within 50 km of data points to 1 and other nodes to NaN, do
  157. ::
  158. gmt grdmask data.xyz -R-60/-40/-40/-30 -I5m -NNaN/1/1 -S50k -Gdata_mask.nc=nb -V
  159. To assign polygon IDs to the gridnodes using the insides of the polygons
  160. in plates.gmt, based on the attribute POL_ID, do
  161. ::
  162. gmt grdmask plates.gmt -R-40/40/-40/40 -I2m -Nz -Gplate_IDs.nc=ns -aZ=POL_ID -V
  163. Same exercise, but instead compute running polygon IDs starting at 100, do
  164. ::
  165. gmt grdmask plates.gmt -R-40/40/-40/40 -I2m -Np100 -Gplate_IDs.nc=ns -V
  166. See Also
  167. --------
  168. :doc:`gmt`, :doc:`grdlandmask`,
  169. :doc:`grdmath`, :doc:`grdclip`,
  170. :doc:`mask`, :doc:`clip`
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...