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
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+7 −3
Original line number Diff line number Diff line
@@ -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