def _get_tile_data_(_filelist, _outfile, _band_order, _tile_specs, _composite_type): _vrtfile = '/vsimem/' + Handler(_outfile).basename.split('.tif')[0] + '_tmp_layerstack.vrt' _outfile = '/vsimem/' + Handler(_outfile).basename.split('.tif')[0] + '_tmp_layerstack.tif' _mraster = MultiRaster(_filelist) _layerstack_vrt = _mraster.layerstack(return_vrt=True, outfile=_outfile) _lras = Raster('_tmp_layerstack') _lras.datasource = _layerstack_vrt _lras.initialize() _lras.make_tile_grid(*_tile_specs) for _ii in range(_lras.ntiles): yield _filelist, _outfile, _band_order, _lras.tile_grid[_ii], _composite_type
lras = Raster('tmp_layerstack') lras.datasource = ls_vrt lras.initialize() xmin, xmax, ymin, ymax = lras.get_pixel_bounds(image_bounds, 'crs') lras.transform = (image_bounds[0], lras.transform[1], lras.transform[2], image_bounds[3], lras.transform[4], lras.transform[5]) lras.shape = [1, (ymax-ymin), (xmax-xmin)] lras.make_tile_grid(*tile_specs) print(len(lras.tile_grid)) Opt.cprint(lras) band_order = list(range(1, len(mraster.rasters) + 1)) out_arr = np.zeros((lras.shape[1], lras.shape[2]), dtype=gdal_array.GDALTypeCodeToNumericTypeCode(lras.dtype)) + \ lras.nodatavalue result_count = 0 for result in pool.map(_tile_process_, _get_tile_data_(filelist, outfile, band_order, tile_specs,