Description
The main goal of xproj
is to provide a reusable way to deal with CRS across Xarray geospatial extensions. This is done using scalar coordinate variables with a CRSIndex
+ a .proj
accessor.
However, one big challenge with this decoupled approach is: how to “link” the CRS-indexed coordinate(s) with other geospatial coordinates, indexes and/or data variables in an Xarray dataset or dataarray?
Some concrete examples:
- accessing the CRS information from within an Xarray index such as
xvec.GeometryIndex
- eventually support (re-)projection (i.e., coordinate transformation and maybe data variable resampling done in 3rd-party Xarray extensions) via something like
.proj.to_crs(…)
We can decompose this issue into the following sub-problems:
- identify spatially-dependent coordinate and data variables in a dataset or dataarray
- in the case of a multi-CRS model (see Single vs. multi CRS datasets #2), link the variables to their corresponding CRS
- expose those links transparently to other Xarray extensions via a convenient API
- ensure those links are kept in-sync when operating on Xarray objects
- trigger data transformation and/or resampling logic implemented elsewhere
CF-conventions address 1 and 2 with the grid_mapping
attribute. Perhaps we could use the same approach here? My main concern is to avoid being too opinionated and going down the rabbit hole by enforcing a too strict CF data model here. Probably a good source of inspiration is to look at how rioxarray
handles that?
One issue with 4 is that operations on Xarray objects can cause (meta)data loss, although this could probably be solved with the combined use of the .proj
accessor and CRSIndex
.
Maybe we can define some protocol for 5?
Thoughts or ideas very much appreciated!