Exemple #1
0
 def test_geotransform_and_friends(self):
     # Assert correct values for file based raster
     self.assertEqual(
         self.rs.geotransform,
         [511700.4680706557, 100.0, 0.0, 435103.3771231986, 0.0, -100.0])
     self.assertEqual(self.rs.origin,
                      [511700.4680706557, 435103.3771231986])
     self.assertEqual(self.rs.origin.x, 511700.4680706557)
     self.assertEqual(self.rs.origin.y, 435103.3771231986)
     self.assertEqual(self.rs.scale, [100.0, -100.0])
     self.assertEqual(self.rs.scale.x, 100.0)
     self.assertEqual(self.rs.scale.y, -100.0)
     self.assertEqual(self.rs.skew, [0, 0])
     self.assertEqual(self.rs.skew.x, 0)
     self.assertEqual(self.rs.skew.y, 0)
     # Create in-memory rasters and change gtvalues
     rsmem = GDALRaster(JSON_RASTER)
     # geotransform accepts both floats and ints
     rsmem.geotransform = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
     self.assertEqual(rsmem.geotransform, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
     rsmem.geotransform = range(6)
     self.assertEqual(rsmem.geotransform, [float(x) for x in range(6)])
     self.assertEqual(rsmem.origin, [0, 3])
     self.assertEqual(rsmem.origin.x, 0)
     self.assertEqual(rsmem.origin.y, 3)
     self.assertEqual(rsmem.scale, [1, 5])
     self.assertEqual(rsmem.scale.x, 1)
     self.assertEqual(rsmem.scale.y, 5)
     self.assertEqual(rsmem.skew, [2, 4])
     self.assertEqual(rsmem.skew.x, 2)
     self.assertEqual(rsmem.skew.y, 4)
     self.assertEqual(rsmem.width, 5)
     self.assertEqual(rsmem.height, 5)
Exemple #2
0
 def test_geotransform_bad_inputs(self):
     rsmem = GDALRaster(JSON_RASTER)
     error_geotransforms = [
         [1, 2],
         [1, 2, 3, 4, 5, 'foo'],
         [1, 2, 3, 4, 5, 6, 'foo'],
     ]
     msg = 'Geotransform must consist of 6 numeric values.'
     for geotransform in error_geotransforms:
         with self.subTest(i=geotransform), self.assertRaisesMessage(
                 ValueError, msg):
             rsmem.geotransform = geotransform