4

I need to modify a very large geoTif file (over 200GB), however when I save it my code crashes as it loads the file in memory. The code looks like this.

import xarray as xr

#  open the file
ds = xr.open_rasterio('file.tif')

# modify here
.....

# this part uses too much memory and gives me the problem
ds.rio.to_raster('output.tif')

Is there any way to save the file as a tif, without loading it all in memory?

ferlix
  • 61
  • 1
  • 5
  • Welcome to stack overflow! [rioxarray supports dask arrays](https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.raster_array.RasterArray.to_raster), so this should work, unless your scheduled tasks blow up the memory. what's in `# modify here`? we need to see all your code to diagnose the issue, ideally as a [mre]. – Michael Delgado Feb 19 '22 at 03:28
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 27 '22 at 17:37

0 Answers0