Skip to content

Commit

Permalink
Change xr_interpolate extent Error to Warning (#1210)
Browse files Browse the repository at this point in the history
* Change `xr_interpolate` extent Error to Warning

* Update tests

* Update docstring
  • Loading branch information
robbibt authored Mar 14, 2024
1 parent a83d913 commit 0a7d2de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Tests/dea_tools/test_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions Tools/dea_tools/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0a7d2de

Please sign in to comment.