Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing shapes in napari_spatialdata results in Z-Polygons that cannot be plotted with pl.render_shapes #230

Closed
pakiessling opened this issue Mar 23, 2024 · 5 comments

Comments

@pakiessling
Copy link

sdata.shapes["Test_shapes"].iloc[0]
> geometry    POLYGON Z ((477.545 825.718 19.000, 433.553 82....)
sdata.pl.render_shapes("Test_shapes").pl.show()
>ValueError: 'vertices' must be 2D with shape (N, 2), but your input has shape (19, 3)
-----
anndata             0.10.6
geopandas           0.14.3
matplotlib          3.8.3
napari_spatialdata  0.3.1
pandas              2.2.1
session_info        1.0.0
shapely             2.0.3
spatialdata         0.0.16
spatialdata_plot    0.1.0

Heya,
Is this expected behavior?

Ty!

@LucaMarconato LucaMarconato transferred this issue from scverse/napari-spatialdata Mar 23, 2024
@LucaMarconato
Copy link
Member

Hi @pakiessling, yes our data model currently assumes shapes (circles, polygons/multiploygons) to be 2D. I will add a check on the parser and validator in ShapesModel and explain this in a new tutorial notebook that I am currently preparing. I suggest to remove the z component. Please try and let me know if it works for you.

If you created the polygon as a napari-spatialdata annotation and you found that it included the z component by default please let as know. We had this problem in the past but it seemed to be fixed; I could look at it again.

@pakiessling
Copy link
Author

I created the problematic polygon in napari-spatialdata.
It came out like this after shift+e.
You mention "napari annotation". I created a new shape layer in napari but there seems to also be the option to create an annotation layer.
Is that different?

@LucaMarconato
Copy link
Member

Thanks, I'll look into this. I suggest to remove the z component, replace the shapes object in-memory and proceed with the analysis.

I will fix the napari behaviour; tracker here: scverse/napari-spatialdata#218.

With "napari annotation" I was referring to the shape layer.

@pakiessling
Copy link
Author

Perfect, thank you!

@LucaMarconato
Copy link
Member

LucaMarconato commented Mar 30, 2024

I fixed it with scverse/napari-spatialdata#228, now napari will only save 2D points and 2D shapes 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants