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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.