Field.coordinate_reference(identity, default=ValueError(), key=False)[source]

Return a coordinate reference construct, or its key.

New in version 3.0.0.


Select the coordinate reference construct by one of:

  • The identity or key of a coordinate reference construct.

A construct identity is specified by a string (e.g. 'grid_mapping_name:latitude_longitude', 'latitude_longitude', 'ncvar%lat_lon', etc.); a Query object (e.g. cf.eq('latitude_longitude')); or a compiled regular expression (e.g. re.compile('^atmosphere')) that selects the relevant constructs whose identities match via

Each construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its identities method. In the following example, the construct x has two identites:

>>> x.identities()
['grid_mapping_name:latitude_longitude', 'ncvar%lat_lon']

A identity’s prefix of 'grid_mapping_name:' or 'standard_name:' may be omitted (e.g. 'standard_name:atmosphere_hybrid_height_coordinate' and 'atmosphere_hybrid_height_coordinate' are both acceptable identities).

A construct key may optionally have the 'key%' prefix. For example 'coordinatereference2' and 'key%coordinatereference2' are both acceptable keys.

Note that in the output of a print call or dump method, a construct is always described by one of its identities, and so this description may always be used as an identity argument.

Parameter example:


Parameter example:


Parameter example:


Parameter example:


Parameter example:


Parameter example:


key: bool, optional

If True then return the selected construct key. By default the construct itself is returned.

default: optional

Return the value of the default parameter if a construct can not be found. If set to an Exception instance then it will be raised instead.

CoordinateReference or str

The selected coordinate reference construct, or its key.