array_to_polygon#
- geowombat.array_to_polygon(data, mask=None, connectivity=4, num_workers=1)#
Converts an
xarray.DataArray` to a ``geopandas.GeoDataFrame
- Parameters:
data (DataArray) – The
xarray.DataArray
to convert.mask (Optional[str, numpy ndarray, or rasterio Band object]) – Must evaluate to bool (rasterio.bool_ or rasterio.uint8). Values of False or 0 will be excluded from feature generation. Note well that this is the inverse sense from Numpy’s, where a mask value of True indicates invalid data in an array. If source is a Numpy masked array and mask is None, the source’s mask will be inverted and used in place of mask. If
mask
is equal to ‘source’, thendata
is used as the mask.connectivity (Optional[int]) – Use 4 or 8 pixel connectivity for grouping pixels into features.
num_workers (Optional[int]) – The number of parallel workers to send to
dask.compute()
.
- Return type:
GeoDataFrame
- Returns:
geopandas.GeoDataFrame
Example
>>> import geowombat as gw >>> >>> with gw.open('image.tif') as src: >>> >>> # Convert the input image to a GeoDataFrame >>> df = gw.array_to_polygon( >>> src, >>> mask='source', >>> num_workers=8 >>> )