Commit 5bca4456 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

raster2polygon() now uses a dynamic zoom factor to avoid crashes ot timeouts...


raster2polygon() now uses a dynamic zoom factor to avoid crashes ot timeouts in case of very large raster arrays.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 03cefd35
...@@ -54,9 +54,9 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None, ...@@ -54,9 +54,9 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
# downsample input array in case is has more than 1e8 pixels to prevent crash # downsample input array in case is has more than 1e8 pixels to prevent crash
if not exact and array.size > 1e8: # 10000 x 10000 px if not exact and array.size > 1e8: # 10000 x 10000 px
zoom_factor = 0.5 zoom_factor = 1e8 / array.size
# downsample to half size, nearest neighbour # downsample with nearest neighbour
from skimage.transform import rescale # import here to avoid static TLS import error from skimage.transform import rescale # import here to avoid static TLS import error
array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(bool) array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(bool)
......
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