-
Notifications
You must be signed in to change notification settings - Fork 12
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
Reprojection produces a GeoBox that does not match when destination CRS is EPSG 4326 #127
Comments
@fbunt that's a limitation of Pixel->World transform representation we use on Xarray objects, and is not Example of the same issue without from odc.geo.geobox import GeoBox
from odc.geo.math import snap_affine
from odc.geo.xr import xr_zeros
src_gb = GeoBox.from_bbox((0.5, 0.5, 10.5, 10.5), shape=(10, 10), crs=3310, tight=True)
dst_gb = src_gb.to_crs(4326)
dst = xr_zeros(dst_gb)
print("GeoBox comparison:", dst.odc.geobox == dst_gb)
print("Shape comparison:", dst.odc.geobox.shape == dst_gb.shape)
print("CRS comparison:", dst.odc.geobox.crs == dst_gb.crs)
print("Affine comparison:", dst.odc.geobox.affine == dst_gb.affine)
print("Area comparison:", (dst.odc.geobox.extent ^ dst_gb.extent).area == 0.0)
print("\ndst_gb affine")
print(repr(dst_gb.affine))
print("\nresult affine")
print(repr(dst.odc.geobox.affine))
# Difference in Affine
A = dst_gb.affine # < desired
A_ = dst.odc.affine # < actual, reconstructed from coords
dA = (~A) * A_ # pixel relation Actual -> Requested
print("\ndiff affine, pixel domain")
print(repr(dA))
print("\ndiff affine, rounded")
display(snap_affine(dA, tol=1e-6))
display(src_gb, dst_gb) out:
1-meter pixel resolution from your example converted to degrees is just too small for float representation to handle without any losses. This issue is more common when working with geographic coordinates because of floating point precision. |
We need an FAQ we can point people to when confusion about pixel coords comes up, |
Ah ok. That makes sense. Thanks! I'm happy to close this if that works for you. |
I ran into this issue while reprojecting some data but I think the underlying cause is that
GeoBox
objects created by different means for the same grid location will have affine transforms that are slightly different. It may be specific to EPSG 4326 since I haven't run into this issue with other projections.When reprojecting to EPSG 4326, the geobox for the result does not match what I input. A short example:
I'm using version 0.4.2.
The text was updated successfully, but these errors were encountered: