diff --git a/Tests/dea_tools/test_spatial.py b/Tests/dea_tools/test_spatial.py index 18b2b6e8b..c1acf6edb 100644 --- a/Tests/dea_tools/test_spatial.py +++ b/Tests/dea_tools/test_spatial.py @@ -417,8 +417,8 @@ def test_xr_interpolate(dem_da, points_gdf, method): k=5, ) - # Verify that error is raised if `gdf` doesn't overlap with `ds` - with pytest.raises(ValueError): + # Verify that warning is raised if `gdf` doesn't overlap with `ds` + with pytest.warns(): xr_interpolate( dem_da, gdf=points_gdf.set_crs("EPSG:3577", allow_override=True), diff --git a/Tools/dea_tools/spatial.py b/Tools/dea_tools/spatial.py index 4917de8ea..8044729a2 100644 --- a/Tools/dea_tools/spatial.py +++ b/Tools/dea_tools/spatial.py @@ -601,7 +601,7 @@ def xr_interpolate( A dataset of spatial points including at least one numeric column. By default all numeric columns in this dataset will be spatially interpolated into the extent of `ds`; specific columns can be - selected using `columns`. An error will be raised if the points + selected using `columns`. An warning will be raised if the points in `gdf` do not overlap with the extent of `ds`. columns : list, optional An optional list of specific columns in gdf` to run the @@ -646,10 +646,10 @@ def xr_interpolate( ds = add_geobox(ds, crs) y_dim, x_dim = ds.odc.spatial_dims - # Reproject to match input `ds`, and raise error if there are no overlaps + # Reproject to match input `ds`, and raise warning if there are no overlaps gdf = gdf.to_crs(ds.odc.crs) if not gdf.dissolve().intersects(ds.odc.geobox.extent.geom).item(): - raise ValueError("The supplied `gdf` does not overlap spatially with `ds`.") + warnings.warn("The supplied `gdf` does not overlap spatially with `ds`.", stacklevel=2) # Select subset of numeric columns (non-numeric are not supported) numeric_gdf = gdf.select_dtypes("number")