Skip to content

Commit f82cae5

Browse files
committed
BUG: Add horizontal_datum_name for geographic CRS in CRS.to_cf
1 parent 8109fc4 commit f82cae5

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

docs/history.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Latest
1313
- REF: Raise error when :meth:`.CRS.to_wkt`, :meth:`.CRS.to_json`, or :meth:`.CRS.to_proj4` returns None (issue #1036)
1414
- CLN: Remove `AzumuthalEquidistantConversion` & :class:`LambertAzumuthalEqualAreaConversion`. :class:`AzimuthalEquidistantConversion` & :class:`LambertAzimuthalEqualAreaConversion` should be used instead (pull #1219)
1515
- BUG: Fix Derived Projected CRS support (issue #1182)
16+
- BUG: Add horizontal_datum_name for geographic CRS in :meth:`.CRS.to_cf`` (issue #1251)
1617

1718
3.4.1
1819
-----

pyproj/crs/crs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ def to_cf(
693693
# handle geographic CRS
694694
if self.geodetic_crs:
695695
cf_dict["geographic_crs_name"] = self.geodetic_crs.name
696+
if self.geodetic_crs.datum:
697+
cf_dict["horizontal_datum_name"] = self.geodetic_crs.datum.name
696698

697699
if self.is_geographic:
698700
if self.coordinate_operation:
@@ -711,8 +713,6 @@ def to_cf(
711713
self.coordinate_operation.method_name.lower()
712714
](self.coordinate_operation)
713715
)
714-
if self.datum:
715-
cf_dict["horizontal_datum_name"] = self.datum.name
716716
else:
717717
cf_dict["grid_mapping_name"] = "latitude_longitude"
718718
return cf_dict

test/crs/test_crs_cf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def test_cf_from_latlon():
221221
"grid_mapping_name": "latitude_longitude",
222222
"geographic_crs_name": "undefined",
223223
"reference_ellipsoid_name": "undefined",
224+
"horizontal_datum_name": "undefined",
224225
}
225226
cf_dict = crs.to_cf()
226227
assert cf_dict.pop("crs_wkt").startswith("GEOGCRS[")
@@ -253,6 +254,7 @@ def test_cf_from_latlon__named():
253254
"reference_ellipsoid_name": "WGS 84",
254255
"longitude_of_prime_meridian": 0.0,
255256
"prime_meridian_name": "Greenwich",
257+
"horizontal_datum_name": "World Geodetic System 1984 ensemble",
256258
"geographic_crs_name": "WGS 84",
257259
"grid_mapping_name": "latitude_longitude",
258260
}

0 commit comments

Comments
 (0)