Skip to content
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

initial set of raster extent functions #85

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elbeejay
Copy link
Member

@elbeejay elbeejay commented Sep 5, 2022

aim is to add some functionality to clip a list of rasters by a common extent (or expand them as necessary to a common extent).

still a lot of work to do on this PR, including but not limited to:

  • testing that it works
  • being more flexible with respect to the "origin" of the raster
  • functionality to "expand" smaller rasters to common extents of larger ones, inserting "nodata" values as appropriate

@jonschwenk
Copy link
Collaborator

Looks nice!

You also might want to add a check that the rasters have the same CRS? I think that can get a little hairy if you rely just on gdal's .GetProjection() since it returns a string that may be more/less verbose for the same CRS. I have some functions that try to extract an EPSG code from a gdal projection string but they felt kinda hacky--I would be surprised if there weren't some packages or more streamlined ways to do this.

You should probably also be clear about the fact that clipping rasters to common extents doesn't ensure that their extents align perfectly since they could potentially differ in resolution that lead to sub-pixel misalignments at the borders. You could address that by adding some resampling code, but I think that's more complicated than you want to go for this. Most use cases are likely rasters from the same source, so they'll have the same resolution and CRS so this is moot.

@elbeejay
Copy link
Member Author

Thanks for the suggestions @jonschwenk. A version of what I'm aiming to do exists within the gdal_calc.py script, so I plan to dig through exactly how they accomplish combining rasters of different extents/projections to get some inspiration and see what aspects of that approach I want to keep, adapt, or alter for this use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants