@@ -76,6 +76,7 @@ def grdfill(
76
76
gridfill : str | xr .DataArray | None = None ,
77
77
neighborfill : float | bool | None = None ,
78
78
splinefill : float | bool | None = None ,
79
+ inquire : bool = False ,
79
80
** kwargs ,
80
81
) -> xr .DataArray | None :
81
82
r"""
@@ -111,6 +112,9 @@ def grdfill(
111
112
hole : float
112
113
Set the node value used to identify a point as a member of a hole [Default is
113
114
NaN].
115
+ inquire
116
+ Output the bounds of each hole. The bounds are 2-D numpy arrays in the form of
117
+ (west, east, south, north). No grid fill takes place and ``outgrid`` is ignored.
114
118
mode : str
115
119
Specify the hole-filling algorithm to use. Choose from **c** for constant fill
116
120
and append the constant value, **n** for nearest neighbor (and optionally append
@@ -155,10 +159,34 @@ def grdfill(
155
159
# Determine the -A option from the fill parameters.
156
160
kwargs ["A" ] = _parse_fill_mode (constantfill , gridfill , neighborfill , splinefill )
157
161
158
- if kwargs .get ("A" ) is None and kwargs .get ("L" ) is None :
159
- msg = "At least parameter 'mode' or 'L' must be specified."
162
+ if kwargs .get ("A" ) is None and not inquire :
163
+ msg = (
164
+ "Need to specify parameter 'constantfill'/'gridfill'/'neighborfill'/"
165
+ "'splinefill' or 'inquire'."
166
+ )
167
+ raise GMTInvalidInput (msg )
168
+ if kwargs .get ("A" ) is not None and inquire :
169
+ msg = (
170
+ "Parameters 'constantfill'/'gridfill'/'neighborfill'/'splinefill' and "
171
+ "'inquire' are mutually exclusive."
172
+ )
160
173
raise GMTInvalidInput (msg )
161
174
175
+ # Inquire only, no grid fill.
176
+ if inquire :
177
+ kwargs ["L" ] = True
178
+ with Session () as lib :
179
+ with (
180
+ lib .virtualfile_in (check_kind = "raster" , data = grid ) as vingrd ,
181
+ lib .virtualfile_out (kind = "dataset" ) as vouttbl ,
182
+ ):
183
+ lib .call_module (
184
+ module = "grdfill" ,
185
+ args = build_arg_list (kwargs , infile = vingrd , outfile = vouttbl ),
186
+ )
187
+ return lib .virtualfile_to_dataset (vfname = vouttbl , output_type = "numpy" )
188
+
189
+ # Fill the grid:
162
190
with Session () as lib :
163
191
with (
164
192
lib .virtualfile_in (check_kind = "raster" , data = grid ) as vingrd ,
0 commit comments