Does GeoUtils reprojection handle GCPs and RPCs ? #640
Replies: 1 comment 4 replies
-
Hi @remi-braun, The short answer is not yet, but soon! Dask support: We indeed finalized our Dask reprojection earlier this year, which is fully tested. It is available here: https://github.com/GlacioHack/geoutils/blob/main/geoutils/raster/delayed.py#L674. But it is not yet public, it will be once we finalize our Xarray GCPs/RPCs: The GCPs/RPCs are only treated as keyword argument right now, they are not discriminated depending on chunks. So they would be passed to all chunks. I'm not so familiar with the use of GCPs/RCPs during reprojection, do you know if passing them as keyword argument to all chunks would be sufficient to work as expected? Or would we need to split them in the chunk metadata somehow? In any case, it feels like it wouldn't be a big task to add support for this. Running your delayed reprojection: In the meantime, if you want to use/adapt the This should look something like this: import xarray as xr
import rioxarray
from geoutils.raster.delayed import delayed_reproject
# Open raster as delayed Dask array through Xarray
filename = "myexample.tif"
chunksizes = (200, 200)
# Or maybe rioxarray.open_rasterio here, not sure if it changes anything
ds = xr.open_dataset(filename, chunks={"x": chunksizes[0], "y": chunksizes[1])
# Specify your output CRS/transform/shape
dst_transform =
dst_shape =
dst_crs =
dst_nodata =
# Call delayed_reproject on dask array stored in ds.data
da_reproj = delayed_reproject(
darr=ds.data,
src_transform=ds.rio.transform(),
src_crs=ds.rio.crs,
dst_transform=dst_transform,
dst_shape=dst_shape,
dst_crs=dst_crs,
resampling=Resampling.bilinear,
src_nodata=ds.rio.nodata,
dst_nodata=dst_nodata,
dst_chunksizes=None, # reproject will use the destination chunksizes if set to None.
)
# Re-build the Xarray object with delayed output before saving
# First, get netCDF coordinates from transform and shape
from rioxarray.rioxarray import affine_to_coords
coords = affine_to_coords(affine=dst_transform, width=dst_shape[0], height=dst_shape[1])
# Copy raster tags/attributes if useful (GCPs, RCPs, potentially updated?)
tags = ds.attrs
# Build a data array
ds_reproj = xr.DataArray(
data=da_reproj,
coords={"x": coords["x"], "y": coords["y"]},
attrs=tags,
)
# Set other attributes
ds_reproj.rio.write_transform(dst_transform)
ds_reproj.rio.set_crs(dst_crs)
ds_reproj.rio.set_nodata(dst_nodata) then you can either perform more operations on the delayed Xarray object, or save to file in a delayed fashion: write_delayed = ds_reproj.to_netcdf("myexample_reproj.tif", compute=False)
write_delayed.compute() Once the We plan to explain clearly out-of-memory support in the documentation once the accessor is out (comparing the |
Beta Was this translation helpful? Give feedback.
-
Hi there!
Thanks for your open source library that seems very promising.
I have one question about your reprojection implementation (which leverages
dask
if I'm right): does it handle GCPs and RPCs ?Beta Was this translation helpful? Give feedback.
All reactions