Commit 731a9ae1 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fix incomplete return values of get_valid_polys() and generally use 4-connectedness.

parent a055e21a
......@@ -58,6 +58,7 @@ def raster2polygon(array: np.ndarray,
:param prj: projection as WKT string, 'EPSG:1234' or <EPSG_int>
:param DN2extract: <int, float> pixel value to create polygons for
:param exact: whether to compute the exact footprint polygon or a simplified one for speed
(exact=False downsamples large input datasets before polygonizing)
:param maxfeatCount: the maximum expected number of polygons. If more polygons are found, every further
processing is cancelled and a RunTimeError is raised.
:param min_npx: minmal polygon area to be included in the result (in numbers of pixels; default: 1)
......@@ -136,7 +137,7 @@ def raster2polygon(array: np.ndarray,
src_band, # .GetMaskBand(),
dst_layer,
0,
[] if exact else ["8CONNECTED=8"], # 4-connectedness for exact output
[], # uses 4-connectedness for exact output (["8CONNECTED=8"] is much slower below)
# callback=gdal.TermProgress_nocb)
callback=callback)
......@@ -171,8 +172,8 @@ def raster2polygon(array: np.ndarray,
val = val if val.is_valid else val.buffer(0)
if isinstance(val, Polygon):
return val
for g in val.geoms:
return get_valid_polys(g)
return [get_valid_polys(g) for g in val.geoms]
# extract polygons from GeoJSON dict
polys = []
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment