def test_copy_layout(self): # Test copy_layout for some rasters files = ["small25.tif", "tunez.tif", "jebja30.tif"] for file in files: b_raster = PRaster() c_raster = PRaster(infolder + "/{0}".format(file)) b_raster.copy_layout(c_raster) size = c_raster.get_size() dims = c_raster.get_dims() ncells = c_raster.get_ncells() cellsize = c_raster.get_cellsize() geot = c_raster.get_geotransform() proj = c_raster.get_projection() computed = (size, dims, ncells, cellsize, geot, proj) size = b_raster.get_size() dims = b_raster.get_dims() ncells = b_raster.get_ncells() cellsize = b_raster.get_cellsize() geot = b_raster.get_geotransform() proj = b_raster.get_projection() expected = (size, dims, ncells, cellsize, geot, proj) self.assertEqual(computed, expected)
def test_projections(self): # Test PRaster getters files = ["small25.tif", "tunez.tif", "jebja30.tif"] for file in files: # Test PRaster getters for a raster raster = PRaster(infolder + "/{0}".format(file)) graster = gdal.Open(infolder + "/{0}".format(file)) self.assertEqual(raster.get_projection(), graster.GetProjection())
def test_empty(self): # Test PRaster getters in an empty PRaster raster = PRaster() size = raster.get_size() dims = raster.get_dims() ncells = raster.get_ncells() cellsize = raster.get_cellsize() geot = raster.get_geotransform() proj = raster.get_projection() computed = (size, dims, ncells, cellsize, geot, proj) expected = ((1, 1), (1, 1), 1, (1.0, -1.0), (0., 1., 0., 0., 0., -1.), "") self.assertEqual(computed, expected)