scverse / scverse/napari-spatialdata

Pass the polygon data to `self._viewer.add_shapes()` in a more efficient way

Open
#56 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
90
Forks
25
Avg merge
22m
Merged PRs (30d)
1

Description

Right now we have the polygons data inside a geodataframe object, and we convert this to a list of list of floats to pass it to self._viewer.add_shapes() with this code

coordinates = polygons.geometry.apply(lambda x: np.array(x.exterior.coords).tolist()).tolist()

which takes 4 seconds for 160K polygons.

We have to check:

  • if there is a better way to access this information within the GeoDataFrame object (maybe some buffer). I don't think this is possible
  • if there is a better way to pass this data to napari, maybe the ragged array representation.
  • if we can parallelize the conversion of this data.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by profiling the shown polygons.geometry.apply(...).tolist() conversion and its call to self._viewer.add_shapes(); the issue names no files or tests. Compare GeoDataFrame access, napari ragged-array input, and parallelization, then benchmark the chosen approach against 160K polygons. Done means a measured improvement with equivalent polygon data rendered correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.