-
Notifications
You must be signed in to change notification settings - Fork 370
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
Fix reprojection issues #1344
Fix reprojection issues #1344
Conversation
|
||
Returns: | ||
the :term:`coordinate reference system (CRS)` | ||
|
||
.. versionadded:: 0.2 |
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.
Although the getter/setter were added in 0.2, the attribute itself has always been present, so technically there was no API change as far as the user is concerned.
dest, _ = rasterio.merge.merge( | ||
vrt_fhs, bounds, self.res, indexes=band_indexes | ||
) | ||
dest, _ = rasterio.merge.merge(vrt_fhs, bounds, self.res, indexes=band_indexes) |
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.
My only concern here is on performance but let's sort that out later. I'm imagining that we can have something like benchmark.py
run during integration tests to test for dataloader performance regressions.
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 recall it being slightly slower (that's why we added the if-statement in the first place), but I'm unaware of any other way of doing this with src.read, so for now if we want boundless reading (needed for GridGeoSampler) then we have to use rasterio.merge.merge.
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.
Sure, but it still stands that this is a place that needs revisiting
dest, _ = rasterio.merge.merge( | ||
vrt_fhs, bounds, self.res, indexes=band_indexes | ||
) | ||
dest, _ = rasterio.merge.merge(vrt_fhs, bounds, self.res, indexes=band_indexes) |
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.
Sure, but it still stands that this is a place that needs revisiting
This PR fixes 2 issues related to reprojection:
I broke this in #1329. When loading any file that requires changing the CRS (and therefore WarpedVRT), we see the following error:
The fix is to always use
rasterio.merge.merge
instead ofsrc.read
, even if there is only a single file. This bug wasn't detected because we don't actually load real files and change the CRS during the RasterDataset tests. I added real files and ensured that we test loading those files with a different CRS.This bug was reported by @jatentaki in #1341. Basically, the following works fine:
However, the following is completely broken:
The fix for this was much more involved. We need to add a res getter/setter to GeoDataset, similar to our crs getter/setter. Then we need to override this in Intersection/UnionDataset to update both datasets. This is updated recursively to ensure that all datasets have matching crs/res. This is a pretty uncommon use case (
ds1 & ds2 & ds3
maps to the former), so that's why no one noticed until now. I added tests for both of the above situations so this doesn't break again.Thanks @jatentaki for reporting this!
Fixes #1341