harpy.sh.vectorize

Contents

harpy.sh.vectorize#

harpy.sh.vectorize(sdata, labels_name, output_shapes_name, instance_key='cell_ID', overwrite=False)#

Vectorize a labels element.

Convert a labels element to a shapes element with name output_shapes_name. If the rasterio library is installed will use implementation based on rasterio, else will use implementation based on skimage. We recommend installing rasterio for increased performance and more precise vectorization.

For optimal performance it is recommended to configure Dask so it uses “processes” instead of “threads”, e.g. via:

>>> import dask
>>> dask.config.set(scheduler='processes')
Parameters:
  • sdata – The SpatialData object to which the new shapes element will be added.

  • labels_name (str) – The labels element to vectorize.

  • output_shapes_name (str) – The name of the output shapes element where the shapes data will be stored.

  • instance_key (str (default: 'cell_ID')) – Name of the resulting index of the GeoDataFrame. The user can set this to any value, it will only be used to name the index.

  • overwrite (bool (default: False)) – If True, overwrites output_shapes_name if it already exists in sdata.

Return type:

SpatialData

Returns:

: The sdata object with the shapes element added.