Skip to content

Commit

Permalink
changed signs in offset calculation to be consistent with QGIS
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasValentin committed Dec 1, 2023
1 parent 31e4cef commit c9a32a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eodal/core/band.py
Original file line number Diff line number Diff line change
Expand Up @@ -2230,24 +2230,24 @@ def scale_data(
scale, offset = self.scale, self.offset
if self.is_masked_array:
if pixel_values_to_ignore is None:
scaled_array = scale * self.values.data - offset
scaled_array = scale * self.values.data + offset
else:
scaled_array = self.values.data.copy().astype(float)
scaled_array[~np.isin(scaled_array, pixel_values_to_ignore)] = scale * \
scaled_array[~np.isin(scaled_array, pixel_values_to_ignore)] \
- offset
+ offset
# reuse fill value
fill_value = self.values.fill_value
scaled_array = np.ma.MaskedArray(
data=scaled_array, mask=self.values.mask, fill_value=fill_value)
elif self.is_ndarray:
if pixel_values_to_ignore is None:
scaled_array = scale * self.values - offset
scaled_array = scale * self.values + offset
else:
scaled_array = self.values.copy().astype(float)
scaled_array[~np.isin(scaled_array, pixel_values_to_ignore)] = scale * \
scaled_array[~np.isin(scaled_array, pixel_values_to_ignore)] \
- offset
+ offset
elif self.is_zarr:
raise NotImplementedError()

Expand Down

0 comments on commit c9a32a0

Please sign in to comment.