sparrow.sh.vectorize

Contents

sparrow.sh.vectorize#

sparrow.sh.vectorize(sdata, labels_layer, output_layer, overwrite=False)#

Vectorize a labels layer.

Convert a labels layer to a shapes layer with name output_layer. 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 perforamnce 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 layer will be added.

  • labels_layer (str) – The labels layer to vectorize.

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

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

Return type:

SpatialData

Returns:

: The sdata object with the shapes layer added.