Skip to content

Data variable CRS #21

Open
Open

Description

@benbovy

Currently Dataset.proj("coord_name").crs can be used to access the CRS of either a spatial reference (scalar) coordinate or a CRS-aware indexed coordinate.

This could probably be extended to data variables as well, which may also be CRS-aware if they have spatial dimensions. Dataset.proj("data_var_name").crs could either return:

  • The CRS returned by Dataset.proj("spatial_ref_name").crs if Dataset["data_var_name"].attrs["grid_mapping"] == "spatial_ref_name" (as inspired by CF conventions)
  • Implicitly fallback to Dataset.proj.crs if there is a unique CRS

To set the CRS of a data variable we could reuse Dataset.map_crs(spatial_ref_name=["data_var_name"]), which will basically (re)set the "grip_mapping" attribute of the given data variable(s).

Activity

  1. dcherian commented on Feb 21, 2025

    @dcherian
    Contributor

    I agree with setting the grid_mapping attribute. My general preference is to encourage users to annotate their data properly rather than rely on implicit behaviour.

  2. benbovy commented on Feb 25, 2025

    @benbovy
    MemberAuthor

    I agree with your preference, instead of a fallback we could simply raise an error with some clear instructions in the message. Manually annotating data may be tedious, though. It would be nice if we could provide some API to help doing that in an automated but explicit way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions