-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor CRS-aware index #27
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
Conversation
ProjIndexMixin class: - replace the ``_proj_get_crs`` abstract method by the ``crs`` abstract (public) property. - add ``_proj_crs_equals`` helper method Xproj now identifies an Xarray index as CRS-aware if it has a ``crs`` property that returns either a ``pyproj.CRS`` object or ``None``. A CRS-aware index may have an undefined CRS (``None``). Add ``CRSAwareIndex`` protocol class.
Copied and adapted from xvec.
# TODO: eventually we won't need to copy the xarray.Index interface here? | ||
# (https://github.com/python/typing/issues/213) |
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.
Unfortunately AFAIK there's no current way around copying the xarray Index interface. I didn't copied the whole Index interface, just the main functions to avoid maintenance hassle.
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.
instead of copying the CRS stuff into RasterIndex I thought it would be nice to have it implemented in a common place (xproj would nicely fit)
I think it'd be great to consolidate if possible!
We already soft depend on xproj so having it as a hard dep makes it only easier. |
If everyone is OK with this, I'm going to proceed like this:
|
Happy to defer to your judgement, @benbovy ! |
I have copied here some CRS-specific code from
xvec
so it can be easily reused elsewhere.@martinfleis -- to give you a bit more context, we are adding CRS-aware functionality to RasterIndex in https://github.com/dcherian/rasterix/pull/31. The functionality is very similar to the CRS functionality implemented in
xvec.GeometryIndex
, so instead of copying the CRS stuff into RasterIndex I thought it would be nice to have it implemented in a common place (xproj would nicely fit).With this PR, we could refactor
xvec.GeometryIndex
like this:and internally reuse the CRS helper methods that are provided by
xproj.ProjIndexMixin
(i.e., move the maintenance of most CRS stuff to xproj). Another benefit is better integration betweenxvec
andxproj
.Of course this would mean that
xproj
becomes a required dependency ofxvec
, but that's probably fine I guess?xproj
only depends on Xarray and Pyproj...If you agree with this, I'm happy to submit a PR to
xvec
after merging this PR and making a new release ofxproj
.