Skip to content
Snippets Groups Projects
Unverified Commit f0b0bba7 authored by Jay Laura's avatar Jay Laura Committed by GitHub
Browse files

Fixes scale and offset missing GeoDataset (#205)

* Fixes scale and offset missing GeoDataset

* Fixes CHANGELOG entry.
parent 28ce2cf5
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,8 @@ release.
-->
## [Unreleased]
### Fixed
- Fixed a bug where scale and offset were not being read or applied to GeoDataset objects.
## [1.5.5]()
### Fixed
......
......@@ -506,6 +506,10 @@ class GeoDataset(object):
"""
band = self.dataset.GetRasterBand(band)
offset = band.GetOffset()
offset = 0 if offset is None else offset
scale = band.GetScale()
scale = 1 if scale is None else scale
if dtype is None:
dtype = GDAL2NP_CONVERSION[band.DataType]
......@@ -513,7 +517,7 @@ class GeoDataset(object):
dtype = getattr(np, dtype)
if not pixels:
array = band.ReadAsArray().astype(dtype)
array = (band.ReadAsArray().astype(dtype) + offset) * scale
#if self.north_up == False:
# array = np.flipud(array)
else:
......@@ -534,7 +538,7 @@ class GeoDataset(object):
if ystart + ycount > ymax:
ycount = ymax - ystart
array = band.ReadAsArray(xstart, ystart, xcount, ycount).astype(dtype)
array = (band.ReadAsArray(xstart, ystart, xcount, ycount).astype(dtype) + offset) * scale
return array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment