Skip to content

Commit

Permalink
avoid warning when converting images with nans
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner committed Dec 14, 2023
1 parent 22760c6 commit ba85510
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions terracotta/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def to_uint8(data: Array, lower_bound: Number, upper_bound: Number) -> Array:
"""Re-scale an array to [1, 255] and cast to uint8 (0 is used for transparency)"""
rescaled = contrast_stretch(data, (lower_bound, upper_bound), (1, 255), clip=True)
rescaled = np.rint(rescaled)
# explicitly set NaNs to 0 to avoid warnings
rescaled[~np.isfinite(rescaled)] = 0
return rescaled.astype(np.uint8)


Expand Down

0 comments on commit ba85510

Please sign in to comment.