Skip to content

Linking CRS with geospatial coordinate or data variables #5

Open
@benbovy

Description

@benbovy

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:

  1. identify spatially-dependent coordinate and data variables in a dataset or dataarray
  2. in the case of a multi-CRS model (see Single vs. multi CRS datasets #2), link the variables to their corresponding CRS
  3. expose those links transparently to other Xarray extensions via a convenient API
  4. ensure those links are kept in-sync when operating on Xarray objects
  5. 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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions