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

Rename SpatialElements #793

Open
Marius1311 opened this issue Nov 22, 2024 · 1 comment
Open

Rename SpatialElements #793

Marius1311 opened this issue Nov 22, 2024 · 1 comment
Labels
enhancement ✨ New feature or request

Comments

@Marius1311
Copy link

Is there an easy way to rename SpatialElements? For example, an image? Not just in memory, but also on disk? I couldn't really find anything in the docs, except for copying the element, creating it with a new name, writing to disk, and deleting the old element both in memory and on disk, but that does seem like an overkill for renaming something. Maybe I'm just missing something here or I have overlooked something

@LucaMarconato LucaMarconato added the enhancement ✨ New feature or request label Jan 5, 2025
@LucaMarconato
Copy link
Member

Hi @Marius1311 thanks for the discussion. Currently there is no API for renaming an element, but indeed it would be useful to have, we will keep this in mind.

If you want to rename images or tables, I suggest to do it outside spatialdata and rename the Zarr folder for the image/table on disk. This applies also for the other elements, with the additional requirement to also eventually modify some metadata.

Precisely:

  • if what is renamed is a points, shapes or labels that is annotated by a table, the table region metadata (adata.uns) needs to be renamed, and also the values of the region_key column.

After this, if you are uploading the data to some cloud storage, you should also regenerate the consolidated metadata. This can be done easily by loading the data and then calling sdata.write_consolidated_metadata().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants