writing with Bigtiff
mmann1123 opened this issue · comments
Michael Mann commented
Note to self. Bigtif can be triggered using config update
with gw.open(bgrn, stack_dim="band") as src:
src.gw.save(
filename=f"../stacks/S2_SR_{quarter}_{grid}.tif",
nodata=nan,
overwrite=True,
num_workers=12,
compress="lzw",
)
RasterioIOError: ../stacks/S2_SR_2020_Q01_linear_south-0000000000-0000000000.tif.tif: The TIFF file will be larger than 4GB, so BigTIFF is necessary. Creation failed.
So write with:
with gw.config.update(bigtiff="yes"):
with gw.open(bgrn, stack_dim="band") as src:
src = src.astype("float32")
src.gw.save(
filename=f"../stacks/S2_SR_{quarter}_{grid}.tif",
nodata=nan,
overwrite=True,
num_workers=12,
compress="lzw",
)
Michael Mann commented
Self q&a here closing
Michael Mann commented
Need to set bounds and bigtif. Maybe bigtif or gdal cache are limited with save
?
Suggested solution
from geowombat.backends.rasterio_ import get_file_bounds
bounds = get_file_bounds( [files], return_bounds=True, )
with gw.config.update(bigtiff="yes", ref_bounds = bounds):
with gw.open(bgrn, stack_dim="band") as src:
src = src.astype("float32")
src.gw.save(
filename=f"../stacks/S2_SR_{quarter}_{grid}.tif",
nodata=nan,
overwrite=True,
num_workers=12,
compress="lzw",
)