Skip to content

Commit

Permalink
Merge pull request #547 from EOxServer/fix-interpolate-overflow
Browse files Browse the repository at this point in the history
Fix overflow in interpolate function
  • Loading branch information
totycro committed Dec 13, 2022
2 parents 2f6c56e + 1d2f86d commit 0efee1c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions eoxserver/render/browse/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def interpolate(ds, x1, x2, y1, y2):
"""Perform linear interpolation for x between (x1,y1) and (x2,y2) """
band = ds.GetRasterBand(1)
x = band.ReadAsArray()
# NOTE: this formula uses large numbers which lead to overflows on uint16
x = x.astype("int64")
x = ((y2 - y1) * x + x2 * y1 - x1 * y2) / (x2 - x1)
return gdal_array.OpenNumPyArray(x, True)

Expand Down

0 comments on commit 0efee1c

Please sign in to comment.