Skip to content

Commit

Permalink
Ensure dtype within _interp_points is floating
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Aug 16, 2024
1 parent c75ef7e commit d36b713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions geoutils/raster/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def _interp_points(
) -> NDArrayNum | Callable[[tuple[NDArrayNum, NDArrayNum]], NDArrayNum]:
"""See description of Raster.interp_points."""

# If array is not a floating dtype (to support NaNs), convert dtype
if not np.issubdtype(array.dtype, np.floating):
array = array.astype(np.float32)

# Get coordinates
x, y = points

Expand Down
1 change: 1 addition & 0 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,7 @@ def interp_points(
:returns rpoints: Array of raster value(s) for the given points.
"""

# Extract array supporting NaNs
array = self.get_nanarray()
if self.count != 1:
array = array[band - 1, :, :]
Expand Down

0 comments on commit d36b713

Please sign in to comment.