2

I'm trying to save the output of a "proccesing" algorithm executed in PyQGIS as a temporal file, and then re-using it with another algorithm. The desired result is to write the output only at the end of the script. I'm working in QGIS 3.2.

 
    from qgis.core import * 
    from PyQt5.QtGui import *
    import processing

path='path/to/output/' parameters = { '-u' : False, 'GRASS_RASTER_FORMAT_META' : '', 'GRASS_RASTER_FORMAT_OPT' : '', 'GRASS_REGION_CELLSIZE_PARAMETER' : 100, 'GRASS_REGION_PARAMETER' : '565000,600000,6220000,6240000 [EPSG:32721]', 'distance' : 0.5, 'exponent' : 0.5, 'flat' : 0, 'high' : 255, 'output' : path + 'rast.tif', 'seed' : None } processing.run('grass7:r.random.surface', parameters) parameters = { 'GRID_IN' : path + 'rast.tif', 'GRID_OUT' : path + 'rast_reclas_v1.sdat', 'LOOKUP' : [0,150,0,151,255,1], 'METHOD' : 2 } processing.run('saga:reclassifyvaluessimple', parameters) parameters = { 'COPY_SUBDATASETS' : False, 'DATA_TYPE' : 5, 'INPUT' : path + 'rast_reclas_v1.sdat', 'NODATA' : None, 'OPTIONS' : '', 'OUTPUT' : path + 'rast_v1.tif', 'TARGET_CRS' : 'EPSG:32721' } processing.run('gdal:translate', parameters)

  • I´m dumb at Python, but whem you export a model as python script, it creates the output just like "'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT". Then the next step has an input as 'INPUT': outputs['stepName']['OUTPUT']. Maybe you should look there. – Herbert Santos Sep 10 '19 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.