Lets say I have two functions:
class AnalyseDTM(): def __init__(self): self.DTM = ('C:/Users/EH/QGis/Kvit_Tiny.tif') self.CreatePolygons() self.test() def CreatePolygons(self): translateFeatures = processing.runAndLoadResults("gdal:translate", { 'INPUT':self.DTM, 'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:5110'), 'NODATA':0, 'COPY_SUBDATASETS':False, 'OPTIONS':'', 'EXTRA':'', 'DATA_TYPE':0, 'OUTPUT': 'TEMPORARY_OUTPUT'}) return !HERE! RemoveSub0values = processing.runAndLoadResults("qgis:rastercalculator", { 'EXPRESSION':'((\"OUTPUT@1\">0)*\"OUTPUT@1\") / ((\"OUTPUT@1\">0)*1 + (\"OUTPUT@1\"<=0)*0)', 'LAYERS': translateFeatures['OUTPUT'], 'CELLSIZE':None, 'EXTENT':None, 'CRS':QgsCoordinateReferenceSystem('EPSG:32633'), 'OUTPUT': 'TEMPORARY_OUTPUT' }) I've removed about 20 other processing functions as the above should hopefully explains what I'm looking for. So you see I have a def CreatePolygons, which currently has two processing. functions in it. This works fine, however I'm wondering if where I have written !HERE! I can separate the two functions. For example I could call it def test(self):
Therefore, I'm wondering if I can pass the 'OUTPUT' from translateFeatures and have it as the input for RemoveSub0values even when they are in separate def 's. I know that if I save it to file and have it in the __init__ then yes, I can, as this is part of a large model I don't want to save multiple outputs to file every time.
I have a fully working class, but its extremely slow, and I therefore wanted to test if grouping processing algorithms would speed this up, but I therefore need to be able to pass temporary outputs between functions.