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)
asked Mar 19, 2023 at 10:42

1 Answer 1

1

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

answered Mar 20, 2023 at 8:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.