Skip to content

Commit

Permalink
adding better test for raster reclass method
Browse files Browse the repository at this point in the history
  • Loading branch information
wbierbower committed Jul 9, 2015
1 parent b62b093 commit 15b1389
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ docs/_build/

# PyBuilder
target/

.DS_Store
14 changes: 8 additions & 6 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tempfile

import numpy as np
from numpy import testing
# from affine import Affine
from fauxgeo.affine import Affine
import gdal
Expand Down Expand Up @@ -157,17 +158,18 @@ def setUp(self):
self.array = np.ones(self.shape)
self.affine = Affine(1, 0, 0, 0, -1, 3)
self.proj = 4326
self.datatype = gdal.GDT_Float64
self.datatype = gdal.GDT_Int16
self.nodata_val = -9999
self.factory = RasterFactory(
self.proj, self.datatype, self.nodata_val, *self.shape, affine=self.affine)

def test_reclass(self):
a = self.factory.alternating(1.0, 2.0)
reclass_dict = {1: 3, 2: 4}
b = a.reclass(reclass_dict)
assert(b.get_band(1)[0, 0] == 3)
assert(b.get_band(1)[0, 1] == 4)
a = self.factory.alternating(1, 2)
reclass_dict = {1: 3.2, 2: 4.3}
b = a.reclass(reclass_dict, out_datatype=gdal.GDT_Float32)

testing.assert_almost_equal(b.get_band(1)[0, 0], 3.2)
testing.assert_almost_equal(b.get_band(1)[0, 1], 4.3, decimal=5)


class TestRasterClip(unittest.TestCase):
Expand Down

0 comments on commit 15b1389

Please sign in to comment.