Skip to content

from_template(): add crs_units and crs_name to result.attrs #3523

Description

@brendancol

Description

from_template() returns a DataArray whose attrs carry res and crs (the EPSG int). The CRS units and the projection's human-readable name both follow from the EPSG code, but neither is surfaced, so a caller inspecting the result has to look them up separately.

Proposed change

Add two keys to the returned attrs:

  • crs_units: the unit of the CRS ("m" for projected templates, "degree" for country codes in EPSG:4326). This is the same value already attached to the x/y coordinate units.
  • crs_name: the projection's human-readable name, for example "NAD83 / Conus Albers" for EPSG:5070 or "WGS 84" for EPSG:4326.

The name is resolved through the existing two-tier CRS path (the LiteCRS built-in table first, then a pyproj fallback). For EPSG codes outside the built-in table when pyproj isn't installed, crs_name is left off rather than raising, so the default non-reproject path stays dependency-free.

Why

It makes the template result self-describing. Downstream code and notebooks can print or assert on the projection name and units without a separate pyproj lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions