zoran-cuckovic / QGIS-visibility-analysis

Quantum GIS plugin for visibility analysis
GNU General Public License v3.0
72 stars 17 forks source link

Viewshed algorithm does not return path to file if temporary output is used #72

Closed kannes closed 6 months ago

kannes commented 1 year ago

When I specify "OUTPUT": QgsProcessing.TEMPORARY_OUTPUT for the visibility:viewshed algorithm, the returned dictionary of results does not include a path to a temporary file (like QGIS' native raster algorithms would).

You can see this too if you execute the algorithm graphically in QGIS' processing toolbox and do not specify a file path to save to:

Eingabeparameter:
{
    "ANALYSIS_TYPE": 0,
    "DEM": "[stripped]",
    "OBSERVER_POINTS": "[stripped]",
    "OPERATOR": 0,
    "OUTPUT": "TEMPORARY_OUTPUT",
    "REFRACTION": 0.13,
    "USE_CURVATURE": False,
}

Execution completed in 0.10 Sekunden
Ergebnisse:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':TEMPORARY_OUTPUT, 'createOptions': {'fileEncoding': 'System'}}>}

vs a working tool like native:createconstantrasterlayer:

Eingabeparameter:
{
    "EXTENT": "[stripped]",
    "NUMBER": 1,
    "OUTPUT": "TEMPORARY_OUTPUT",
    "OUTPUT_TYPE": 5,
    "PIXEL_SIZE": 111,
    "TARGET_CRS": QgsCoordinateReferenceSystem("EPSG:25832"),
}

Execution completed in 0.08 Sekunden
Ergebnisse:
{'OUTPUT': '/tmp/processing_vUgXtq/bd28c750529d4a8089dee19cce3967e5/OUTPUT.tif'}

This behaviour makes it impossible to use the viewshed analysis in a chain of processing.run() calls to other algorithms and potentially also the modeller?

kannes commented 1 year ago

This can be used as a workaround currently:

        for output in self.outputDefinitions():
            outputName = output.name()

            if outputName in parameters :
                results[outputName] = parameters[outputName]
                results["OUTPUT"] = output_path
zoran-cuckovic commented 1 year ago

Thanks for this input ! I'll consider this for the next version.

zoran-cuckovic commented 6 months ago

Fixed in 1.9 version (pending approval)