Rename SpatialElements
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
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
regionmetadata (adata.uns) needs to be renamed, and also the values of theregion_keycolumn.
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().