REWRITTEN project raster via GDALWarp() app lib #1220
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this another attempt at #1216, it's not substantially different but exposes the new behaviour as an option from R.
Propose to use GDALWarp utility library for
project()
raster rather than with ChunkAndWarpImage.The benefit is automatic choice of a reasonable overview for multi-zoom sources (like large GeoTIFFs or image tile servers), (and hence very fast read, with data resolution suitable for target raster even over large regions.
The problem remains that we only access bands from the first source. see below
(This doesn't address the capability for collections, but I think it's worth sharing as is now because that will require a solution for the multiple sources, and maybe that can just be done at the R level).
Currently is a lot slower in terra for online image servers and very large COGs because there's no overview detection and it defaults to having to scan the highest resolution tiles, for small local regions the current capability is fast because only a small number of tiles are visited.
The PR does the following
set_warp_options()
, I've left the working inline inwarper()
project()
to add aby_util
argument to allow invoking this pathway from RGDALwarp()
was librarified in 2.1.0 so this should be supported by all terra installs.Examples
Created on 2023-07-04 with reprex v2.0.2
Problem
I don't think GDALWarp() can work this way for multi-source
SpatRaster
(at least, not until version 3.7.0), because with multiple sources you are writing to specific bands in the destination dataset. In 3.7.0 you can explicitly set up 'srcbands' and 'dstbands' as options for the GDALWarpAppOptions. I don't think this can be achieved until then without reworking how the multple bands in a multi-source SpatRaster are collated.So we could set
project()
to warn or error on multi-source inputs, which I suggest is a good way to go. I think it would be rare to generate multi-source rast objects from very large online sources.