Reproject large raster using Python

23 Views Asked by At

I have some large rasters that I want to reproject in a memory-safe way, using a second raster as a template . This code works nicely for smaller ones, but when they are large the Python kernel becomes unresponsive and crashes. I believe it's a memory issue. How can I reproject large rasters, with the result being written to a tif file?

import rasterio
import rioxarray
import xarray

my_raster = rioxarray.open_rasterio("large.tif")

reference = rioxarray.open_rasterio("template_large_tif")

reprojected = my_raster.rio.reproject_match(reference)

reprojected.rio.to_raster("output.tif")
0

There are 0 best solutions below