-
I am trying to reproject a large raster, using a second raster as a template. This works fine on smaller rasters, but crashes with larger ones. I think I probably need to use window'd read and writes but I'm unsure how to implement this or if it's the correct solution. Thanks.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Re-project match just uses the same CRS, transform, and shape of the other raster: rioxarray/rioxarray/raster_array.py Line 552 in 6b768ec Examples referenced in solution: Solution: import rasterio
import rasterio.vrt
import rioxarray
with rasterio.open("large.tif") as src, rasterio.open("template_large.tif") as template:
with rasterio.vrt.WarpedVRT(
src,
crs=template.crs,
transform=template.transform,
height=template.height,
width=template.width,
) as vrt:
rds = rioxarray.open_rasterio(vrt, lock=False, parse_coordinates=False)
rds.rio.to_raster("output.tif", tiled=True, windowed=True) |
Beta Was this translation helpful? Give feedback.
-
reproject match is like this template_raster = rioxarray.open_rasterio('template_raster.tif')
useraster = rioxarray.open_rasterio('useraster.tif')
finalraster = useraster.rio.reproject_match(template_raster)
finalraster = finalraster.assin_coords({"x":template_raster.x, "y":template_raster.y}) #so they match exactly |
Beta Was this translation helpful? Give feedback.
Re-project match just uses the same CRS, transform, and shape of the other raster:
rioxarray/rioxarray/raster_array.py
Line 552 in 6b768ec
Examples referenced in solution:
Solution: