def read_band(self, blocksize=CHUNK_SIZE):
        """Read the band in chunks."""
        band = self.filehandle

        shape = band.shape
        if len(band.block_shapes) == 1:
            total_size = blocksize * blocksize * 1.0
            lines, cols = band.block_shapes[0]
            if cols > lines:
                hblocks = cols
                vblocks = int(total_size / cols / lines)
            else:
                hblocks = int(total_size / cols / lines)
                vblocks = lines
        else:
            hblocks = blocksize
            vblocks = blocksize
        vchunks = range(0, shape[0], vblocks)
        hchunks = range(0, shape[1], hblocks)

        token = tokenize(hblocks, vblocks, band)
        name = 'read_band-' + token

        def do_read(the_band, the_window, the_lock):
            with the_lock:
                return the_band.read(1, None, window=the_window)

        dskx = {(name, i, j): (do_read, band,
                               Window(hcs, vcs,
                                      min(hblocks,  shape[1] - hcs),
                                      min(vblocks,  shape[0] - vcs)),
                               self.read_lock)
                for i, vcs in enumerate(vchunks)
                for j, hcs in enumerate(hchunks)
                }

        res = da.Array(dskx, name, shape=list(shape),
                       chunks=(vblocks, hblocks),
                       dtype=band.dtypes[0])
        return DataArray(res, dims=('y', 'x'))
def read_band ( self , blocksize = CHUNK_SIZE ) : band = self . filehandle shape = band . shape if len ( band . block_shapes ) == 1 : total_size = blocksize * blocksize * 1.0 lines , cols = band . block_shapes [ 0 ] if cols > lines : hblocks = cols vblocks = int ( total_size / cols / lines ) else : hblocks = int ( total_size / cols / lines ) vblocks = lines else : hblocks = blocksize vblocks = blocksize vchunks = range ( 0 , shape [ 0 ] , vblocks ) hchunks = range ( 0 , shape [ 1 ] , hblocks ) token = tokenize ( hblocks , vblocks , band ) name = 'read_band-' + token def do_read ( the_band , the_window , the_lock ) : with the_lock : return the_band . read ( 1 , None , window = the_window ) dskx = { ( name , i , j ) : ( do_read , band , Window ( hcs , vcs , min ( hblocks , shape [ 1 ] - hcs ) , min ( vblocks , shape [ 0 ] - vcs ) ) , self . read_lock ) for i , vcs in enumerate ( vchunks ) for j , hcs in enumerate ( hchunks ) } res = da . Array ( dskx , name , shape = list ( shape ) , chunks = ( vblocks , hblocks ) , dtype = band . dtypes [ 0 ] ) return DataArray ( res , dims = ( 'y' , 'x' ) )
Read the band in chunks.