From 302e1a3ffc4761ffdd71170133d17794cbb19dcc Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:18:19 +0330 Subject: [PATCH 1/6] docs: correct shapely_to_cf suffix parameter --- cf_xarray/geometry.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 289f456f..f3560140 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -441,8 +441,11 @@ def shapely_to_cf( A CF grid mapping name. When given, coordinates and attributes are named and set accordingly. Defaults to None, in which case the coordinates are simply names "crd_x" and "crd_y". - container_name: str, optional - Name for the "geometry container" scalar variable in the encoded Dataset + suffix : str, optional + Suffix appended to generated geometry variable and + dimension names. For example, "_a" produces names + such as "geometry_container_a" and "node_a". + Defaults to an empty string. Returns ------- From e33a01a45ab453d9b5a3ede2cc16b2b1b6dc5b0d Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:21:11 +0330 Subject: [PATCH 2/6] docs: document cf_to_shapely container parameter --- cf_xarray/geometry.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index f3560140..5277c280 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -519,6 +519,10 @@ def cf_to_shapely(ds: xr.Dataset, *, container: Hashable = GEOMETRY_CONTAINER_NA Must contain a ``geometry_container`` variable with attributes giving the geometry specifications. Must contain all variables needed to reconstruct the geometries listed in these specifications. + container : Hashable, optional + Name of the geometry container variable in ``ds``. + Defaults to ``"geometry_container"``. + Returns ------- da: xr.DataArray From 2cd1b0d55e2fe529964128349c4dca92713d9eab Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:33:41 +0330 Subject: [PATCH 3/6] docs: cross-reference geometry conversion functions --- cf_xarray/geometry.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 5277c280..8489bbec 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -458,6 +458,10 @@ def shapely_to_cf( - 'interior_ring' : Integer boolean indicating whether rings are interior or exterior. Only for Polygons with holes. - container_name : Empty variable with attributes describing the geometry type. + See Also + -------- + cf_to_shapely : Convert CF-compliant geometry data to Shapely objects. + References ---------- Please refer to the CF conventions document: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries @@ -530,6 +534,10 @@ def cf_to_shapely(ds: xr.Dataset, *, container: Hashable = GEOMETRY_CONTAINER_NA It has the same dimension as the ``node_count`` or the coordinates variables, or ``features`` if those were not present in ``ds``. + See Also + -------- + shapely_to_cf : Convert Shapely geometries to CF-compliant data. + References ---------- Please refer to the CF conventions document: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries From c827c5addc78f41cf3ed474a5b06020c0aa77d81 Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:41:44 +0330 Subject: [PATCH 4/6] docs: add shapely_to_cf usage example --- cf_xarray/geometry.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 8489bbec..29e655f9 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -458,6 +458,14 @@ def shapely_to_cf( - 'interior_ring' : Integer boolean indicating whether rings are interior or exterior. Only for Polygons with holes. - container_name : Empty variable with attributes describing the geometry type. + Examples + -------- + >>> from shapely.geometry import Point + >>> import cf_xarray as cfxr + >>> encoded = cfxr.shapely_to_cf([Point(0, 0), Point(1, 1)], suffix="_a") + >>> "geometry_container_a" in encoded + True + See Also -------- cf_to_shapely : Convert CF-compliant geometry data to Shapely objects. From 99050f8c796342389c4734c5a97c3f81b3e015a7 Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:48:25 +0330 Subject: [PATCH 5/6] docs: add cf_to_shapely usage example --- cf_xarray/geometry.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 29e655f9..bd1e5b80 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -542,6 +542,15 @@ def cf_to_shapely(ds: xr.Dataset, *, container: Hashable = GEOMETRY_CONTAINER_NA It has the same dimension as the ``node_count`` or the coordinates variables, or ``features`` if those were not present in ``ds``. + Examples + -------- + >>> from shapely.geometry import Point + >>> import cf_xarray as cfxr + >>> encoded = cfxr.shapely_to_cf([Point(0, 0)], suffix="_a") + >>> decoded = cfxr.cf_to_shapely(encoded, container="geometry_container_a") + >>> decoded.values[0].equals(Point(0, 0)) + True + See Also -------- shapely_to_cf : Convert Shapely geometries to CF-compliant data. From 6fce5b58c86b5558a75eec315a04c5c3801b4b91 Mon Sep 17 00:00:00 2001 From: Aisun <193120803+AisunZa@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:59:57 +0330 Subject: [PATCH 6/6] docs: polish geometry conversion descriptions --- cf_xarray/geometry.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index bd1e5b80..897bf8b0 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -456,7 +456,8 @@ def shapely_to_cf( - 'node_count' : The number of nodes per feature. Always present for Lines and Polygons. For Points: only present if there are multipart geometries. - 'part_node_count' : The number of nodes per individual geometry. Only for Lines with multipart geometries and for Polygons with multipart geometries or holes. - 'interior_ring' : Integer boolean indicating whether rings are interior or exterior. Only for Polygons with holes. - - container_name : Empty variable with attributes describing the geometry type. + - 'geometry_container' (plus suffix, if specified) : Scalar + variable with attributes describing the geometry type. Examples -------- @@ -469,7 +470,7 @@ def shapely_to_cf( See Also -------- cf_to_shapely : Convert CF-compliant geometry data to Shapely objects. - + References ---------- Please refer to the CF conventions document: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries