-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDALWarp applib for project() #1216
Conversation
Given that this changes a lot and breaks, could you perhaps implement this as a separate function? That would allow for easy comparison with the current implementation; and perhaps for using one over the other for particular cases. |
ok for sure, I wanted to flag interest with it working - and getting there was a minor personal accomplishment 😅👌 I've been using it for a long time to read into mem and create files and I can't work without being able to do that with these sources now. One other thing terra doesn't allow here is multiple sources that have different grid, and simply letting GDAL pick the output grid. I'll think about how that might work, because it's really a single step - define a grid (or lean on gdal suggested) and send in source/s, so a new R function makes sense, and would encapsulate my other #1175 . |
I've made a version with
https://github.com/mdsumner/terra/tree/mdsumner-warp-by-utils-app1 Examples here: https://gist.github.com/mdsumner/872a167b5b69898e96611768cbd0e1d9 still needs thought for the align/resample/mask options (if they belong), and for filename and driver choice which should be trivial to do - the use-cases I see are just
but other options could be added by loading up |
Thanks (for what is forthcoming)
It rarely makes much sense to me to let GDAL pick the output raster geometry; but I think it is a good idea to add a |
oh right, yes, I had meant to explore that, that covers enough the thing that does make sense about gdal picking is that you can provide one (or two or three or none) of dim, res, ext, crs, and because some sources don't have a regular grid already (the rectify case, or GCPs, or #1175 and **) - but I'm keen to get this going as you suggested and have learnt a lot about terra internals now! **gdalwarp will output a reasonable resolution and extent in longlat for any source with geolocation arrays with no options set, for example |
I said that it might be a good idea to add a |
oh cool that's good, I'll explore - GDAL's suggested warp output could be a lot better, and your align model is very cool - impose is a better verb than project I think 👌 |
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).
ChunkAndWarpImage
scales to out of memory usage but is not currently being used for that atm, I think this is equivalent to current capability but can quickly read overviews from massive remote sources (without workarounds).(off-topic but relevant, GDALWarp can also be directed to an out of memory data store but does its own determination of the chunking required afaik)
The examples below are reasonably quick for large regions with this PR. It's currently a lot slower in terra 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()
GDALwarp()
was librarified in 2.1.0 so this should be supported by all terra installs.Example
Created on 2023-06-30 with reprex v2.0.2
Problems
I cannot get it to work with multiple sources, I will update if I figure it out
The second source doesn't have valid values after warping e.g.