-
Notifications
You must be signed in to change notification settings - Fork 20
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
Handling a ROI when loading raster data #642
base: main
Are you sure you want to change the base?
Conversation
3e25dec
to
33fbbac
Compare
Great addition, thanks @vschaffn! 🙂 I have a main remark about the As it happens, the
In short, doing: rst = Raster("file.tif")
rst_cropped = rst.crop(my_roi) worked without loading the full dataset. We had been debating about adding the windowed reading of Maybe this is the occasion to merge things together? |
Additionally, by merging like this, all the existing tests we have for |
@rhugonnet I had not noticed that the crop() method already worked with the data not loaded on disk. After studying _crop() function, I think the simplest thing is to restore _load_rio() without ROI, and to use crop, as it is, before _load_rio() if a ROI is passed when the raster is initialised. This will effectively mean that there is only one function dealing with the ROI, and therefore simplified code maintenance 😃 |
@vschaffn Yes that's true, this would work as well 🙂. The difference would be only internal to make |
Okay for me, we can open an issue for the |
Hi all, I'm slowly trying to catch up, and sorry if some of it should have come up earlier during the conception... One more thing to consider. We should make sure that crop and ROI (if kept separate) behave the same way when the ROI is partially or fully out of the raster bounds. I had to check with crop, but it looks like it does not raise any warning or error if the bound is larger (but silently crops to the maximum extent) and raises an error if there is no intersection at all between the two. See example below. Maybe we should raise a warning when the requested crop partially overlap and an error when it does not overlap at all?
|
I agree, we should make the naming and behaviour fully consistent between |
Link towards Rioxarray nomenclature for the same functionality This could be the occasion to define a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can put the copyright CNES.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THE CI is failing because of the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the copyright CNES is added, the CI working and @adehecq or @rhugonnet agreed the changes please feel free to merge during this week.
@adebardo I fixed the documentation issue in the CI, and I added CNES copyright to |
Resolves GlacioHack/xdem#602
Resolves #645
Description
This PR introduces the functionality for handling a Region of Interest (ROI) in pixels when loading raster data.
Changes
Raster.icrop()
method to handle ROI in pixels.Test
test_icrop()
intest_raster
to ensure the good behavior when cropping a rasterDoc
Raster.icrop()
along withRaster.crop()
in doc, and making it clear that the crops are also functional when the Raster is not loaded into memory.