Skip to content

assign "spatial ref" variable attrs #32

Open

Description

@dcherian
diffcrs.proj.assign_crs(spatial_ref="epsg:4326")

for a dataset without an existing spatial_ref, this will create a new spatial_ref variable with no attrs. This is confusing because if the spatial_ref variable was present, those existing attrs will be preserved (and possibly out-of-date).

I think it would be good to be consistent here --- either the spatial ref always has attributes (kept in sync with the index) or it never has attributes.

Activity

  1. benbovy commented on Jun 30, 2025

    @benbovy
    Member

    Agreed. It is possible to always have attributes kept in sync with the index (by implementing CRSIndex.create_variables()). However, we would need to choose and stick with one set of conventions for the attributes, and we would need to handle that in .proj.write_crs_info().

    We should also check for conflicts between the CRS passed as an option and any existing attribute of an existing spatial_ref (I don't think we're doing it currently).

  2. dcherian commented on Jun 30, 2025

    @dcherian
    ContributorAuthor

    Another confusing one is when there is no spatial_ref variable, it is created with no attributes.

    ds = xr.tutorial.open_dataset("ersstv5")
    ds.proj.assign_crs(spatial_ref="epsg:4326")
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions