Example #1
0
    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)
Example #2
0
 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)
Example #3
0
 def test_properties(self):
     # Test PRaster getters
     files = ["small25.tif", "tunez.tif", "jebja30.tif"]
     for file in files:
         raster = PRaster(infolder + "/{0}".format(file))
         size = raster.get_size()
         dims = raster.get_dims()
         ncells = raster.get_ncells()
         cellsize = raster.get_cellsize()
         geot = raster.get_geotransform()
         computed = (size, dims, ncells, cellsize, geot)
         graster = gdal.Open(infolder + "/{0}".format(file))
         band = graster.GetRasterBand(1)
         arr = band.ReadAsArray()
         ggeot = graster.GetGeoTransform()
         expected = ((band.XSize, band.YSize), arr.shape, arr.size,
                     (ggeot[1], ggeot[5]), ggeot)
         self.assertEqual(computed, expected)