Skip to content

Commit 4385a20

Browse files
committed
extra fix annotations
1 parent c3cd50a commit 4385a20

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/napari_spatialdata/_viewer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,14 @@ def _save_shapes_to_sdata(
253253
np.array([layer_to_save.data_to_world(xy) for xy in shape._data])
254254
for shape in layer_to_save._data_view.shapes
255255
]
256-
remove_z = coords[0].shape[1] == 3
257-
first_index = 1 if remove_z else 0
258-
polygons: list[Polygon] = [Polygon(p[::-1, first_index:]) for p in coords]
256+
257+
def _fix_coords(coords: np.ndarray) -> np.ndarray:
258+
remove_z = coords.shape[1] == 3
259+
first_index = 1 if remove_z else 0
260+
coords = coords[:, first_index::]
261+
return np.fliplr(coords)
262+
263+
polygons: list[Polygon] = [Polygon(_fix_coords(p)) for p in coords]
259264
# polygons: list[Polygon] = [Polygon(i) for i in _transform_coordinates(coords, f=lambda x: x[::-1])]
260265
# polygons: list[Polygon] = [Polygon(i) for i in _transform_coordinates(layer_to_save.data, f=lambda x: x[::-1])]
261266
gdf = GeoDataFrame({"geometry": polygons})

0 commit comments

Comments
 (0)