def test_set_raster_origin(self): data, coords = georef.set_raster_origin(self.data.copy(), self.coords.copy(), 'upper') np.testing.assert_array_equal(data, self.data) np.testing.assert_array_equal(coords, self.coords) data, coords = georef.set_raster_origin(self.data.copy(), self.coords.copy(), 'lower') np.testing.assert_array_equal(data, np.flip(self.data, axis=-2)) np.testing.assert_array_equal(coords, np.flip(self.coords, axis=-3))
def test_create_raster_dataset(self): data, coords = georef.set_raster_origin(self.data.copy(), self.coords.copy(), 'upper') ds = georef.create_raster_dataset(data, coords, projection=self.proj, nodata=-32768) data, coords, proj = georef.extract_raster_dataset(ds) np.testing.assert_array_equal(data, self.data) np.testing.assert_array_almost_equal(coords, self.coords) self.assertEqual(proj.ExportToWkt(), self.proj.ExportToWkt())
def test_set_raster_indexing(self): data, coords = georef.set_raster_origin( self.data.copy(), self.coords.copy(), "lower" ) data, coords = georef.set_raster_indexing(data, coords, "ij") np.testing.assert_array_equal( data, np.swapaxes(np.flip(self.data, axis=-2), 0, 1) ) np.testing.assert_array_equal( coords, np.swapaxes(np.flip(self.coords, axis=-3), 0, 1) ) data, coords = georef.set_raster_indexing(data, coords, "xy") np.testing.assert_array_equal(data, np.flip(self.data, axis=-2)) np.testing.assert_array_equal(coords, np.flip(self.coords, axis=-3))
def test_create_raster_dataset(self): data, coords = georef.set_raster_origin( self.data.copy(), self.coords.copy(), "upper" ) ds = georef.create_raster_dataset( data, coords, projection=self.proj, nodata=-32768 ) data, coords, proj = georef.extract_raster_dataset(ds) np.testing.assert_array_equal(data, self.data) np.testing.assert_array_almost_equal(coords, self.coords) assert proj.ExportToWkt() == self.proj.ExportToWkt() data, coords = georef.set_raster_origin( self.data2.copy(), self.coords2.copy(), "upper" ) ds = georef.create_raster_dataset( data, coords, projection=self.proj, nodata=-32768 ) data, coords, proj = georef.extract_raster_dataset(ds, mode="edge") np.testing.assert_array_equal(data, self.data2) np.testing.assert_array_almost_equal(coords, self.coords2) assert proj.ExportToWkt() == self.proj.ExportToWkt()