Skip to content

Commit 0a7d2de

Browse files
authored
Change xr_interpolate extent Error to Warning (#1210)
* Change `xr_interpolate` extent Error to Warning * Update tests * Update docstring
1 parent a83d913 commit 0a7d2de

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Tests/dea_tools/test_spatial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ def test_xr_interpolate(dem_da, points_gdf, method):
417417
k=5,
418418
)
419419

420-
# Verify that error is raised if `gdf` doesn't overlap with `ds`
421-
with pytest.raises(ValueError):
420+
# Verify that warning is raised if `gdf` doesn't overlap with `ds`
421+
with pytest.warns():
422422
xr_interpolate(
423423
dem_da,
424424
gdf=points_gdf.set_crs("EPSG:3577", allow_override=True),

Tools/dea_tools/spatial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def xr_interpolate(
601601
A dataset of spatial points including at least one numeric column.
602602
By default all numeric columns in this dataset will be spatially
603603
interpolated into the extent of `ds`; specific columns can be
604-
selected using `columns`. An error will be raised if the points
604+
selected using `columns`. An warning will be raised if the points
605605
in `gdf` do not overlap with the extent of `ds`.
606606
columns : list, optional
607607
An optional list of specific columns in gdf` to run the
@@ -646,10 +646,10 @@ def xr_interpolate(
646646
ds = add_geobox(ds, crs)
647647
y_dim, x_dim = ds.odc.spatial_dims
648648

649-
# Reproject to match input `ds`, and raise error if there are no overlaps
649+
# Reproject to match input `ds`, and raise warning if there are no overlaps
650650
gdf = gdf.to_crs(ds.odc.crs)
651651
if not gdf.dissolve().intersects(ds.odc.geobox.extent.geom).item():
652-
raise ValueError("The supplied `gdf` does not overlap spatially with `ds`.")
652+
warnings.warn("The supplied `gdf` does not overlap spatially with `ds`.", stacklevel=2)
653653

654654
# Select subset of numeric columns (non-numeric are not supported)
655655
numeric_gdf = gdf.select_dtypes("number")

0 commit comments

Comments
 (0)