Skip to content

Commit 96a00d8

Browse files
committed
fix
1 parent 8a6b79f commit 96a00d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cf_xarray/geometry.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,18 @@ def grid_to_polygons(ds: xr.Dataset) -> xr.DataArray:
338338
latbnd = points[lat_bounds].data
339339

340340
if points.sizes[bounds_dim] == 2:
341-
# geopandas needs this
342341
lonbnd = lonbnd[..., [0, 0, 1, 1]]
343-
mask = lonbnd[..., 0] >= 180
344-
lonbnd[mask, :] = lonbnd[mask, :] - 360
345342
latbnd = latbnd[..., [0, 1, 1, 0]]
346343

347344
elif points.sizes[bounds_dim] != 4:
348345
raise ValueError(
349346
f"The size of the detected bounds or vertex dimension {bounds_dim} is not 2 or 4."
350347
)
351348

349+
# geopandas needs this
350+
mask = lonbnd[..., 0] >= 180
351+
lonbnd[mask, :] = lonbnd[mask, :] - 360
352+
352353
polyarray = shapely.polygons(shapely.linearrings(lonbnd, latbnd))
353354

354355
# 'geometry' is a blessed name in geopandas.

0 commit comments

Comments
 (0)