Commit 7ba26ff3 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

WIP: complete refactoring of stratification application.

parent 20b2c9ed
......@@ -112,16 +112,26 @@ class GetStratificationMap(QgsProcessingAlgorithm):
to_del = []
grm_pre = os.path.join(tmp_folder, prefix + '_segraw.tif')
grm_pre = os.path.join(tmp_folder, prefix + 'segraw.tif')
grm_params = {'in': metric, 'out': grm_pre, 'criterion': 'bs', 'criterion.bs.cw': cw, 'criterion.bs.sw': sw, 'threshold': threshold}
processing.run('otb:LSGRM', grm_params, context=context, feedback=feedback)
to_del.append(grm_pre)
ndt = os.path.join(tmp_folder, prefix + '_segndt.tif')
ndt_params = {'il': [metric, grm_pre], 'exp': 'im1b1 != ' + str(ndv) + ' ? im2b1 : 0'}
ndt_params = {'il': [metric, grm_pre], 'exp': 'im1b1 != ' + str(ndv) + ' ? im2b1 : 0', 'out': ndt}
processing.run('otb:BandMath', ndt_params, context=context, feedback=feedback)
to_del.append(ndt)
vec = output_vector
vec_params = {'in': ndt, 'out': vec}
out = processing.run('otb:SimpleVectorization', vec_params, context=context, feedback=feedback)
for x in to_del:
try:
os.remove(x)
except:
warnings.warn('Could not remove ' + x)
if len(os.listdir(tmp_folder)) == 0:
os.rmdir(tmp_folder)
return {self.OUTPUT: out}
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