- vectorize(xds: Union[str, DataArray, Dataset, DatasetReader], values: Union[None, int, list] = None, keep_values: bool = True, dissolve: bool = False, default_nodata: int = 0) GeoDataFrame #
xarrayto get the class vectors.
If dissolved is False, it returns a GeoDataFrame with a GeoSeries per cluster of pixel value, with the value as an attribute. Else it returns a GeoDataFrame with a unique polygon.
Your data is casted by force into np.uint8, so be sure that your data is classified.
This could take a while as the computing time directly depends on the number of polygons to vectorize.
Please be careful.
>>> raster_path = "path/to/raster.tif" >>> vec1 = vectorize(raster_path) >>> # or >>> with rasterio.open(raster_path) as ds: >>> vec2 = vectorize(ds) >>> vec1 == vec2 True
xds (PATH_XARR_DS) – Path to the raster or a rasterio dataset or a xarray
keep_values (bool) – Keep the passed values. If False, discard them and keep the others.
dissolve (bool) – Dissolve all the polygons into one unique. Only works if values are given.
default_nodata (int) – Default values for nodata in case of non existing in file
- Return type: