1

I am working on a script in which I am rasterising a vector using Rasterio.

When I try to write the raster to a tif file, my cluster runs out of memory and crashes about 30 seconds after the job starts.

Is there a more memory friendly way in which I can save this as a tif file using Rasterio?

My code is below:

with rasterio.open(
        os.path.join(dir, filename), "w",
        driver="GTiff",
        transform=raster.transform,
        dtype=rasterio.float32,
        count=1,
        crs=raster.crs,
        width=raster.width,
        height=raster.height) as dst:
    dst.write(array, indexes = 1)

1 Answer 1

1

You could use rioxarray (library that mixes rasterio and xarray) to chunk your input data and write it using dask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.