Commit a691dc4c authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed syntax.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent ff9fa33d
Pipeline #22784 failed with stage
in 1 minute and 46 seconds
......@@ -54,7 +54,8 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
# downsample with nearest neighbour
zoom_factor = (8000 * 8000 / array.size) ** 0.5
array, gt, prj = warp_ndarray(array, gt, prj,
out_gsd=(gt[1] / zoom_factor, gt[5] / zoom_factor),
out_gsd=(gt[1] / zoom_factor,
gt[5] / zoom_factor),
rspAlg='near',
q=True)
......@@ -85,7 +86,11 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
if progress and not q else Timer(timeout, use_as_callback=True) if timeout else None
# run the algorithm
status = gdal.Polygonize(src_band, src_band.GetMaskBand(), mem_layer, 0, ["8CONNECTED=8"] if exact else [],
status = gdal.Polygonize(src_band,
src_band.GetMaskBand(),
mem_layer,
0,
["8CONNECTED=8"] if exact else [],
callback=callback)
# handle exit status other than 0 (fail)
......@@ -95,6 +100,9 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
raise TimeoutError('raster2polygon timed out!')
raise Exception(errMsg)
except KeyboardInterrupt:
raise TimeoutError('raster2polygon timed out!')
# extract polygon
mem_layer.SetAttributeFilter('DN = %s' % DN2extract)
......
Markdown is supported
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