Bug report #18110

Unable to create a tempory raster when calling IDW SAGA from python ('NoneType' object has no attribute 'source')

Added by Jean Hemmi almost 7 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:Victor Olaya
Category:Processing/SAGA
Affected QGIS version:3.0.0 Regression?:Yes
Operating System:Win 10 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:26006

Description

Following question #17714 which has been closed.

I am able to call SAGA IDW from the processing interface (after changing order in extent : YMIN have to be changed from third position to second). see screencopy "OK Running SAGA IDW"

My problem : I cannot call this alg asking for a temporary raster file (passing None under 2.14 is not valid under 3.0) from Python console. i have experienced a temp name and QgsProcessingOutputRasterLayer
see screencopy "Question IDW KO for temp file"

Here is my test code :

from processing.core.Processing import Processing
Processing.initialize()
versionSAGA = processing.algs.saga.SagaUtils.getInstalledVersion()
print( versionSAGA)
info_extent= '796018.2658206049,6674128.609732771,796079.989864021,6674254.041102098 [EPSG:2154]'
IDW_SAGA = { 'SHAPES' : 'D:/GIS/DATA/POINTS_L93.shp',
'FIELD' : 'DIAM', 'DW_WEIGHTING' : 1, 'DW_IDW_POWER' : 2, 'DW_IDW_OFFSET' : False, 'DW_BANDWIDTH' : 1,
'SEARCH_RANGE' : 0, 'SEARCH_RADIUS' : 100, 'SEARCH_POINTS_ALL' : 0,
'SEARCH_POINTS_MIN' : 1, 'SEARCH_POINTS_MAX' : 10, 'SEARCH_DIRECTION' : 0,
'OUTPUT_EXTENT' : info_extent, 'TARGET_USER_SIZE' : 100, 'TARGET_DEFINITION' : 1, 'TARGET_USER_FITS' : 0,
'TARGET_TEMPLATE' : '',
'TARGET_OUT_GRID' : 'C:/Users/Utilisateur/AppData/Local/Temp/processing_30acb258f1ae40db85c6dd6a0f0ab5aa/f17c58dbd75747269ca73df49c2a4b6h/TARGET_OUT_GRID.sdat' }
print( IDW_SAGA)
processing.run("saga:inversedistanceweightedinterpolation", IDW_SAGA)

log when sagaAlgoritm crashes :

2018-02-15T10:55:03 CRITICAL Traceback (most recent call last):
File "C:/PROGRA~1/QGIS2~1.99/apps/qgis-dev/./python/plugins\processing\algs\saga\SagaAlgorithm.py", line 170, in processAlgorithm
exportCommand = self.exportRasterLayer(param.name(), layer)
File "C:/PROGRA~1/QGIS2~1.99/apps/qgis-dev/./python/plugins\processing\algs\saga\SagaAlgorithm.py", line 372, in exportRasterLayer
if layer.source() in sessionExportedLayers:
AttributeError: 'NoneType' object has no attribute 'source'

Running QGIS3 B4be39f98b
SAGA is 2.3.2

OK Running SAGA IDW from processing.png - OK Running SAGA IDW (163 KB) Jean Hemmi, 2018-02-15 11:12 AM

IDW KO unable to call for a temporary file.png - Question IDW KO for temp file (140 KB) Jean Hemmi, 2018-02-15 11:12 AM

POINTS_L93.zip - shapefile for test (12.7 KB) Jean Hemmi, 2018-02-15 11:24 AM

History

#1 Updated by Alexander Bruy over 6 years ago

  • Assignee deleted (Alexander Bruy)

#2 Updated by Giovanni Manghi over 6 years ago

  • Priority changed from Normal to High

#3 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Open to Feedback

I'm not sure I understand how to replicate the issue. Is about when you run the tool and let it create a temp file instead of saving the result to a specific disk location and format?

In the meantime #18183, #18187 and #18188

#4 Updated by Jean Hemmi over 6 years ago

Giovanni Manghi wrote:

I'm not sure I understand how to replicate the issue. Is about when you run the tool and let it create a temp file instead of saving the result to a specific disk location and format?

In the meantime #18183, #18187 and #18188

My question can be resume by #18183 ('TARGET_OUT_GRID' : None is not accepted by QGIS3).
During my first test, i've try to let the tool create the raster and during a second test, i've not found how to specify a result to a specific location.
Issue 18187 is another problem (described in the screenshot "OK Running SAGA IDW")

#5 Updated by Jean Hemmi over 6 years ago

  • Status changed from Feedback to Open

The problem is on under 3.0.0-Girona 001c80b0c3

#6 Updated by Giovanni Manghi over 6 years ago

  • Affected QGIS version changed from master to 3.0.0

#7 Updated by Jean Hemmi over 6 years ago

  • Assignee set to Victor Olaya

I'had mentionned that related probleme #18183 can resume this issue but my question is :

Unable to call Saga IDW from python console TARGET_OUT_GRID : 'None' is not accepted

How can i call Saga IDW from python console and keep result in a temporary file ?

#8 Updated by Jean Hemmi over 6 years ago

  • Assignee deleted (Victor Olaya)

I'have experienced the same problème under Linux &
Qgis 3.1.0-Master Révision du code 871132eae6

Saga is 2.3.1.
algo this time is library : Spline Interpolation
tool : Cubic Spline Approximation

{ 'SHAPES' : '/data/GIS/DATA/DATA_PHY/SORTIE_PHY/PHY3/vecteur/PHY3_POINTS_SANS_0_L93.shp', 'FIELD' : 'DIAM', 'NPMIN' : 3, 'NPMAX' : 20, 'NPPC' : 5, 'K' : 140, 'OUTPUT_EXTENT' : '795825.2212942,796084.9317131,6674126.9668843,6674710.7083225 [EPSG:2154]', 'TARGET_USER_SIZE' : 100, 'TARGET_USER_FITS' : 0, 'TARGET_OUT_GRID' : '/tmp/processing_7d21d13f385c482c9d0e8c84b92e4203/3fc12265eec64e1c82a4523436a15f23/TARGET_OUT_GRID.sdat' }

grid_spline "Cubic Spline Approximation" -TARGET_DEFINITION 0 -SHAPES "/data/GIS/DATA/DATA_PHY/SORTIE_PHY/PHY3/vecteur/PHY3_POINTS_SANS_0_L93.shp" -FIELD "DIAM" -NPMIN 3 -NPMAX 20 -NPPC 5 -K 140.0 -TARGET_USER_XMIN 795825.2212942 -TARGET_USER_XMAX 796084.9317131 -TARGET_USER_YMIN 6674126.9668843 -TARGET_USER_YMAX 6674710.7083225 -TARGET_USER_SIZE 100.0 -TARGET_USER_FITS 0 -TARGET_OUT_GRID "/tmp/processing_7d21d13f385c482c9d0e8c84b92e4203/3fc12265eec64e1c82a4523436a15f23/TARGET_OUT_GRID.sdat"

The raster file is created OK when using "Processing dialog".

It is KO from python console and from a python plugin.

Thanks for your help.

#9 Updated by Jean Hemmi over 6 years ago

  • Assignee set to Victor Olaya

I had un-assigned by error.

Thanks for any help

#10 Updated by Jean Hemmi over 6 years ago

  • Status changed from Open to Closed

For IDW SAGA problem 'NoneType' object has no attribute 'source'
was 'TARGET_TEMPLATE' : '' is not supported but 'TARGET_TEMPLATE' : None is ignored by processing.

Tested on Windows & Linux.
Solved & closed as a user-error.

Also available in: Atom PDF