qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.6k stars 3.01k forks source link

Processing/GRASS tool fails to generate output when temporary output memory is used #41719

Open wmeinolf opened 3 years ago

wmeinolf commented 3 years ago

Hi, in my scripts for FTTH Networks I heavily use the GRASS features v.clean, v.net and v.net.steiner. When they didn't provide output I found, that once I use a dedicated file for output instead of 'output': QgsProcessing.TEMPORARY_OUTPUT, everything worked fine. The problem with this workaround is, that I get lots and lots of temporary GPKG files, which I heed to delete manually form time to time. Interestingly since a while, v.clean does work with 'output': QgsProcessing.TEMPORARY_OUTPUT, v.net and v.net.steiner do still not.

Here how I use v.clean (works fine):

   alg_params = {
        '-b': False,
        '-c': True,
        'GRASS_MIN_AREA_PARAMETER': 0.0001,
        'GRASS_OUTPUT_TYPE_PARAMETER': 2,
        'GRASS_REGION_PARAMETER': None,
        'GRASS_SNAP_TOLERANCE_PARAMETER': 1,
        'GRASS_VECTOR_DSCO': '',
        'GRASS_VECTOR_EXPORT_NOCAT': False,
        'GRASS_VECTOR_LCO': '',
        'input': outputs['NochmalAlleFelderAusserHighwayFeldLschen1']['OUTPUT'],
        'threshold': '',
        'tool': [0],
        'type': [1],
        'error': QgsProcessing.TEMPORARY_OUTPUT,
        'output': QgsProcessing.TEMPORARY_OUTPUT
    }
    outputs['VcleanMitBreakUndNachfolgeOhneEinrasten'] = processing.run('grass7:v.clean', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

Here how I currently need to use v.net.steiner, to get it work: alg_params = { '-g': False, 'GRASS_MIN_AREA_PARAMETER': 0.0001, 'GRASS_OUTPUT_TYPE_PARAMETER': 0, 'GRASS_REGION_PARAMETER': None, 'GRASS_SNAP_TOLERANCE_PARAMETER': -1, 'GRASS_VECTOR_DSCO': '', 'GRASS_VECTOR_EXPORT_NOCAT': False, 'GRASS_VECTOR_LCO': '', 'acolumn': '', 'arc_type': [0,1], 'input': outputs['DoppelteGeometrienHighwayAusgestanztGesprengtGeloeschtohneFid']['OUTPUT'], # war mal: outputs['FtthPlanungSub2StrassenConnectedAufgelstReprojizieren']['OUTPUT'], 'npoints': -1, 'points': outputs['HaUndKvzggfPopPositionenZusammenfasssen']['OUTPUT'], 'terminalcats': '1-100000', 'threshold': 50, 'output': 'C:\Users\WMeinolf\QGIS Root\temp\vsteinertmp'+str(LOOPUID)+'.gpkg' } outputs['Vnetsteiner'] = processing.run('grass7:v.net.steiner', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

where LOOPUID is required to gett diffrernt unique GPKG names in loops: LOOPUID = QgsExpression(' substr(uuid(),2,36) ').evaluate()

Here my question: Do I do anything wrong, or is it a BUG either in QGIS or in the GRASS modules v.net and v.net.steiner? Thanks for you support!

I like to refer to issue "Processing/GRASS tool fails to generate output" #40499, which seems to similar but was closed due to lack of feedback.


I'm on WIndows 10, German UI, QGIS installed with OSGeo4W64

QGIS-Version 3.16.3-Hannover QGIS-Codeversion 94ac9f21b8
Kompiliert gegen Qt 5.11.2 Laufendes Qt 5.11.2
Kompiliert mit GDAL/OGR 3.1.4 Läuft mit GDAL/OGR 3.1.4
Kompiliert mit GEOS 3.8.1-CAPI-1.13.3 Läuft mit GEOS 3.8.1-CAPI-1.13.3
Kompiliert mit SQLite 3.29.0 Läuft mit SQLite 3.29.0
PostgreSQL-Client-Version 11.5 SpatiaLite-Version 4.3.0
QWT-Version 6.1.3 QScintilla2-Version 2.10.8
Kompiliert mit PROJ 6.3.2 Läuft mit PROJ Rel. 6.3.2, May 1st, 2020
BS-Version Windows 10 (10.0)
Aktive Python-Erweiterungen closest_points; disconnected-islands; ImportPhotos; joinmultiplelines; lizmap; meinotestplugin; mmqgis; networks; ORStools; pluginbuilder3; plugin_reloader; qchainage; qgis-bulk-nominatim-master; Qgis2threejs; qgis2web; QuickOSM; refFunctions; db_manager; MetaSearch; processing
wmeinolf commented 3 years ago

I have no idea, why the "Won't fix" Lable has been added!

gioman commented 3 years ago

I have no idea, why the "Won't fix" Lable has been added!

@wmeinolf because you choose the wrong option here https://github.com/qgis/QGIS/issues/new/choose

gioman commented 3 years ago

Here my question: Do I do anything wrong, or is it a BUG either in QGIS or in the GRASS modules v.net and v.net.steiner? Thanks for you support!

@wmeinolf please attach your script and a sample of data we can use with it.

wmeinolf commented 3 years ago

Hi, the attached ZIP contains a QGIS plus GPKG as well as my scripts. I did not attach the style files, they should not matter.

You find the relevant parts in script "Schritt 5 Wegenetz erstellen" lines 578 and 579 for v.net same in "Schritt 6 Tiefbaustrecken ermitteln" lines 437 and 428 for v.net.steiner. It always works with my local temp file, it never works, once QgsProcessing.TEMPORARY_OUTPUT is used.

To reproduce just load qgs and start "Schritt 5 Wegenetz erstellen", which shpuld run w/o error. Then switch # at 578 and 579 and run script again. Script schouls stop with error like in the protocol at bottom.

Let me know, if you need more info. Cheers Wolfgang

vnetbugdemo.zip

--------------------------------------- log file------------------------------------ QGIS-Version: 3.16.3-Hannover QGIS-Codeversion: 94ac9f21b8 Qt-Version: 5.11.2 GDAL-Version: 3.1.4 GEOS-Version: 3.8.1-CAPI-1.13.3 PROJ-Version: Rel. 6.3.2, May 1st, 2020 Verarbeite Algorithmus… Algorithmus Schritt 5 Wegenetz erstellen v2 07.02.21 startet… Eingabeparameter: { 'HausPunkte' : 'C:/Users/WMeinolf/QGIS Root/temp/210222 v.net.steinerTest.gpkg|layername=Hauspunkte', 'KVZStandortLayer' : 'C:/Users/WMeinolf/QGIS Root/temp/210222 v.net.steinerTest.gpkg|layername=KVZ Standorte', 'POPStandortLayer' : 'C:/Users/WMeinolf/QGIS Root/temp/210222 v.net.steinerTest.gpkg|layername=POP Standort', 'PufferbreiteumAusbauBereich' : 500, 'Strassenbreite' : 3, 'VERBOSE_LOG' : False }

ProjectBasename ist: 210222 v.net.steinerTest ProjectFilename ist: C:/Users/WMeinolf/QGIS Root/temp/210222 v.net.steinerTest.qgz ProjectPath ist: C:/Users/WMeinolf/QGIS Root/temp ProjectBasename ist: 210222 v.net.steinerTest Wert features ist: <qgis._core.QgsFeatureIterator object at 0x000001A3EBC103A8> Wert featurecount ist: 21 ############################################

Start Berechnung Wegenetz für kompletten Ausbaubereich

############################################ Ergebnisse: {'OUTPUT': 'Begrenzende_Geometrie_0d431355_0ebd_47d4_86ec_4dd9e919ebee'} Ergebnisse: {'OUTPUT': 'Gepuffert_537c6331_9c74_4b64_bd54_14bc5a879cf6'} Ergebnisse: {'OUTPUT_OQL_QUERY': '\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n', 'OUTPUT_URL': 'https://lz4.overpass-api.de/api/interpreter?data=%3Cosm-script output%3D%22xml%22 timeout%3D%22500%22%3E%0A %3Cunion%3E%0A %3Cquery type%3D%22node%22%3E%0A %3Chas-kv k%3D%22highway%22/%3E%0A %3Cbbox-query e%3D%228.665550906620435%22 n%3D%2248.841559531840645%22 s%3D%2248.82230188418485%22 w%3D%228.63060322722993%22/%3E%0A %3C/query%3E%0A %3Cquery type%3D%22way%22%3E%0A %3Chas-kv k%3D%22highway%22/%3E%0A %3Cbbox-query e%3D%228.665550906620435%22 n%3D%2248.841559531840645%22 s%3D%2248.82230188418485%22 w%3D%228.63060322722993%22/%3E%0A %3C/query%3E%0A %3Cquery type%3D%22relation%22%3E%0A %3Chas-kv k%3D%22highway%22/%3E%0A %3Cbbox-query e%3D%228.665550906620435%22 n%3D%2248.841559531840645%22 s%3D%2248.82230188418485%22 w%3D%228.63060322722993%22/%3E%0A %3C/query%3E%0A %3C/union%3E%0A %3Cunion%3E%0A %3Citem/%3E%0A %3Crecurse type%3D%22down%22/%3E%0A %3C/union%3E%0A %3Cprint mode%3D%22body%22/%3E%0A%3C/osm-script%3E&info=QgisQuickOSMPlugin'} Ergebnisse: {'OUTPUT': 'C:/Users/WMeinolf/AppData/Local/Temp/processing_qFbPiG/2350ff1496234b4483dc2ac7cf34cc66/OUTPUT.file'} Ergebnisse: {'CONCATENATION': 'C:/Users/WMeinolf/AppData/Local/Temp/processing_qFbPiG/2350ff1496234b4483dc2ac7cf34cc66/OUTPUT.file|layername=lines'} Ergebnisse: {'OUTPUT': 'ExtrahiertAttribut493950ce_5e2e_4f96_bb31_11fba4550567'} Ergebnisse: {'OUTPUT': 'Überarbeitet_9af287bb_51ee_4758_af2a_6ce4171e56d1'} Ergebnisse: {'OUTPUT': 'Reprojiziert_b99f963f_646d_4660_9a2f_e38afd8ff4be'} Ergebnisse: {'FAIL_OUTPUT': 'Nicht_passend_2afc6a4c_e43e_4633_8017_bbeedd8ab8db', 'OUTPUT': 'Passende_Objekte_5d716c1a_9d41_4f9f_8859_34087ff2f9e3'} Ergebnisse: {'OUTPUT': 'Nicht_passend_2afc6a4c_e43e_4633_8017_bbeedd8ab8db'} Ergebnisse: {'OUTPUT': 'Gepuffert_cf46b1fa_44f4_4d9f_95a3_e1c4636dc6e2'} Ergebnisse: {'OUTPUT': 'Linien_71f34a2b_d3b0_41f2_9997_8e82763f6ae6'} 150 Geometrien eingerastet. Ergebnisse: {'OUTPUT': 'Eingerastete_Geometrien_0f733c2d_f215_428d_a433_0926b1643e5c'} Ergebnisse: {'OUTPUT': 'Einzelne_Teile_0ffef6b6_fec1_4dfa_a677_ff6ad086d714'} Ergebnisse: {'OUTPUT': 'Aufgelöst_15ddcc8a_f99c_499a_bec0_bc14ad4d5a79'} Angegebenes Ziel-KBS EPSG:25832 verwenden Ausgabetype auf LineString gesetzt Layer 1/2 wird paketiert: Nicht passend Layer 2/2 wird paketiert: Einzelne Teile Ergebnisse: {'OUTPUT': 'Zusammengeführt_f4ebc7d9_865a_4117_abe1_13642dd63c6d'} Status: Vor v.clean Zeile 289 Ergebnisse: {'OUTPUT': 'Überarbeitet_7ef562e0_1b51_4e1f_8a0e_e7c3f69e0be3'} g.proj -c proj4="+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" v.in.ogr min_area=0.0001 snap=1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\05e20058220246c087e7f9e83a18a8bf\input.shp" output="vector_60336f2f500468" --overwrite -o g.region n=5410244.913335299 s=5407307.4268757505 e=476104.16679019964 w=472166.0297337928 v.clean input=vector_60336f2f500468 type="line" tool="break" -c output=outputd60802690b9548bdb931ee4a4660477f error=errord60802690b9548bdb931ee4a4660477f --overwrite v.out.ogr type="line" input="outputd60802690b9548bdb931ee4a4660477f" output="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\0f2467ccd74a441b8111d3cd59be9f15\output.gpkg" format="GPKG" --overwrite v.out.ogr type="line" input="errord60802690b9548bdb931ee4a4660477f" output="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\48521629b199465186239c4e0803b3bb\error.gpkg" format="GPKG" --overwrite Starting GRASS GIS... WARNUNG: Sperren gleichzeitiger Zugriffe auf ein Mapset ist unter Windows nicht möglich. Cleaning up temporary files... Executing <C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\grassdata\grass_batch_job.cmd> ... C:\Users\WMeinolf\Documents>chcp 1252 1>NUL C:\Users\WMeinolf\Documents>g.proj -c proj4="+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" Die Standard Region wurde auf die neue Projektion aktualisiert. Wenn Sie aber mehrere Mapsets haben, sollten Sie g.region -d in jedem ausführen, um die Einstellungen von der Standardregion zu übernehmen. Projektionsinformationen aktualisiert C:\Users\WMeinolf\Documents>v.in.ogr min_area=0.0001 snap=1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\05e20058220246c087e7f9e83a18a8bf\input.shp" output="vector_60336f2f500468" --overwrite -o Übersteuere Projektionsprüfung Check if OGR layer contains polygons... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100 Creating attribute table for layer ... Importing 320 features (OGR layer )... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100

Erstelle Topologie für die Vektorkarte vector_60336f2f500468@PERMANENT... Registriere Primitive... C:\Users\WMeinolf\Documents>g.region n=5410244.913335299 s=5407307.4268757505 e=476104.16679019964 w=472166.0297337928 C:\Users\WMeinolf\Documents>v.clean input=vector_60336f2f500468 type="line" tool="break" -c output=outputd60802690b9548bdb931ee4a4660477f error=errord60802690b9548bdb931ee4a4660477f --overwrite

Werkzeug: Schwellwert Teile: 0

Kopiere Objekte... 2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100 Erstelle Teile der Topologie neu... Erstelle Topologie für die Vektorkarte outputd60802690b9548bdb931ee4a4660477f@PERMANENT... Registriere Primitive...

Tool: Split lines Werkzeug: Teile Linien an Überschneidungen 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100 Werkzeug: Entferne doppelte Vektoren 1..3..5..7..9..11..13..15..17..19..21..23..25..27..29..31..33..35..37..39..41..43..45..47..49..51..53..55..57..59..61..63..65..67..69..71..73..75..77..79..81..83..85..87..89..91..93..95..97..99..100 Tool: Merge lines 2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100

Erstelle erneut Topologie für die Ausgabe-Vektorkarte... Erstelle Topologie für die Vektorkarte outputd60802690b9548bdb931ee4a4660477f@PERMANENT... Registriere Primitive...

Erstelle Topologie für die Fehler-Vektorkarte... Erstelle Topologie für die Vektorkarte errord60802690b9548bdb931ee4a4660477f@PERMANENT... Registriere Primitive... C:\Users\WMeinolf\Documents>v.out.ogr type="line" input="outputd60802690b9548bdb931ee4a4660477f" output="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\0f2467ccd74a441b8111d3cd59be9f15\output.gpkg" format="GPKG" --overwrite Exporting 1846 features... 5..11..17..23..29..35..41..47..53..59..65..71..77..83..89..95..100 v.out.ogr komplett. 2153 features (Line String type) written to (GPKG format). C:\Users\WMeinolf\Documents>v.out.ogr type="line" input="errord60802690b9548bdb931ee4a4660477f" output="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\48521629b199465186239c4e0803b3bb\error.gpkg" format="GPKG" --overwrite WARNUNG: 1002 points found, but not requested to be exported. Verify 'type' parameter. WARNUNG: Keine Attributtabelle gefunden -> benutze nur Kategorienummern als Attributes. Exporting 3007 features... 5..11..17..23..29..35..41..47..53..59..65..71..77..83..89..95..100 v.out.ogr komplett. 3105 features (Line String type) written to (GPKG format). C:\Users\WMeinolf\Documents>exit Execution of <C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\grassdata\grass_batch_job.cmd> finished. Cleaning up default sqlite database ... Cleaning up temporary files... Ergebnisse: {'error': 'C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\48521629b199465186239c4e0803b3bb\error.gpkg', 'output': 'C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\0f2467ccd74a441b8111d3cd59be9f15\output.gpkg'} Status: Nach v.clean Zeile 330 Ergebnisse: {'OUTPUT': 'Reprojiziert_af7e7ee2_849b_404c_afbc_b58ecfa2f070'} Ergebnisse: {'OUTPUT': 'Überarbeitet_d7cc69fe_1277_464c_8ec3_3cfc73f1479e'} Angegebenes Ziel-KBS EPSG:25832 verwenden Ausgabetype auf Point gesetzt Layer 1/3 wird paketiert: Hauspunkte Layer 2/3 wird paketiert: KVZ Standorte Layer 3/3 wird paketiert: POP Standort Ergebnisse: {'OUTPUT': 'Zusammengeführt_bb459aa4_941a_4e97_b4f7_cbf337f67006'} g.proj -c proj4="+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\cf3ef3968f13461aa7af0e2b94e405d2\input.shp" output="vector_60336f32dc3429" --overwrite -o v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\69491db121a04807985946d4bc432154\points.shp" output="vector_60336f32eb73210" --overwrite -o g.region n=5410244.913335299 s=5407307.4268757505 e=476104.16679019964 w=472166.0297337928 v.net input=vector_60336f32dc3429 points=vector_60336f32eb73210 operation="connect" threshold=500 arc_type="line" output=output6ab2dfbccfd347bfa40c219277289908 --overwrite v.out.ogr type="line" input="output6ab2dfbccfd347bfa40c219277289908" output="C:/Users/WMeinolf/AppData/Local/Temp/processing_qFbPiG/580bd2044be54983aea420907214f9e3/output.gpkg" format="GPKG" layer=1 --overwrite Starting GRASS GIS... WARNUNG: Sperren gleichzeitiger Zugriffe auf ein Mapset ist unter Windows nicht möglich. Cleaning up temporary files... Executing <C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\grassdata\grass_batch_job.cmd> ... C:\Users\WMeinolf\Documents>chcp 1252 1>NUL C:\Users\WMeinolf\Documents>g.proj -c proj4="+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" Die Standard Region wurde auf die neue Projektion aktualisiert. Wenn Sie aber mehrere Mapsets haben, sollten Sie g.region -d in jedem ausführen, um die Einstellungen von der Standardregion zu übernehmen. Projektionsinformationen aktualisiert C:\Users\WMeinolf\Documents>v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\cf3ef3968f13461aa7af0e2b94e405d2\input.shp" output="vector_60336f32dc3429" --overwrite -o Übersteuere Projektionsprüfung Check if OGR layer contains polygons... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100 Creating attribute table for layer ... Importing 2153 features (OGR layer )... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100

Erstelle Topologie für die Vektorkarte vector_60336f32dc3429@PERMANENT... Registriere Primitive... C:\Users\WMeinolf\Documents>v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\69491db121a04807985946d4bc432154\points.shp" output="vector_60336f32eb73210" --overwrite -o Übersteuere Projektionsprüfung Check if OGR layer contains polygons... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100 Creating attribute table for layer ... Column name renamed to Column name renamed to Column name renamed to Column name renamed to Column name renamed to Column name <ist Baulüc> renamed to Column name <Kennung -> renamed to Column name renamed to Column name renamed to Importing 834 features (OGR layer )... 0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100

Erstelle Topologie für die Vektorkarte vector_60336f32eb73210@PERMANENT... Registriere Primitive... C:\Users\WMeinolf\Documents>g.region n=5410244.913335299 s=5407307.4268757505 e=476104.16679019964 w=472166.0297337928 C:\Users\WMeinolf\Documents>v.net input=vector_60336f32dc3429 points=vector_60336f32eb73210 operation="connect" threshold=500 arc_type="line" output=output6ab2dfbccfd347bfa40c219277289908 --overwrite Kopiere Objekte... 2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100 Erstelle Topologie für die Vektorkarte output6ab2dfbccfd347bfa40c219277289908@PERMANENT... Registriere Primitive... Kopiere Attribute... Erstelle Topologie für die Vektorkarte output6ab2dfbccfd347bfa40c219277289908@PERMANENT... Registriere Primitive... v.net komplett. 1655 lines (network arcs) written to output. C:\Users\WMeinolf\Documents>v.out.ogr type="line" input="output6ab2dfbccfd347bfa40c219277289908" output="C:/Users/WMeinolf/AppData/Local/Temp/processing_qFbPiG/580bd2044be54983aea420907214f9e3/output.gpkg" format="GPKG" layer=1 --overwrite WARNUNG: 834 points found, but not requested to be exported. Verify 'type' parameter. Exporting 3808 features... 5..11..17..23..29..35..41..47..53..59..65..71..77..83..89..95..100 831 features without attributes were written v.out.ogr komplett. 3808 features (Line String type) written to (GPKG format). C:\Users\WMeinolf\Documents>exit Execution of <C:\Users\WMeinolf\AppData\Local\Temp\processing_qFbPiG\grassdata\grass_batch_job.cmd> finished. Cleaning up default sqlite database ... Cleaning up temporary files... Ergebnisse: {'output': 'TEMPORARY_OUTPUT'}

+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+# Nach v.net

Kann Algorithmus nicht ausführen Konnte Quelllayer für INPUT nicht laden: TEMPORARY_OUTPUT nicht gefunden Kann Algorithmus nicht ausführen Konnte Quelllayer für INPUT nicht laden: TEMPORARY_OUTPUT nicht gefunden Ausführung nach 17.52 Sekunden gescheitert

Lade Ergebnis Layer Algorithmus 'Schritt 5 Wegenetz erstellen v2 07.02.21' beendet

gioman commented 3 years ago

This seems the key

Unable to execute algorithm
Could not load source layer for INPUT: TEMPORARY_OUTPUT not found
Unable to execute algorithm
Could not load source layer for INPUT: TEMPORARY_OUTPUT not found
Execution failed after 11.80 seconds
tombrennan06 commented 3 years ago

I've had the same problem using GRASS (grass:) and WhiteBox Tools (wbt:) processing algorithms via PyQGIS (Windows 10, QGIS 3.12). If the 'output' parameter is set to 'TEMPORARY_OUTPUT', the output variable does not get set to a file path. It is set instead to the string 'TEMPORARY_OUTPUT'

eg a GRASS algorithm >>> resultThin = processing.run("grass7:r.thin",{ 'GRASS_RASTER_FORMAT_META' : '', 'GRASS_RASTER_FORMAT_OPT' : '', 'GRASS_REGION_CELLSIZE_PARAMETER' : 0, 'GRASS_REGION_PARAMETER' : None, 'input' : resultPreThin['OUTPUT'], 'iterations' : 200, 'output' : QgsProcessing.TEMPORARY_OUTPUT }) >>> resultThin['output'] 'TEMPORARY_OUTPUT'

Native (qgis:, native:), SAGA (saga:) and GDAL (gdal:) processsing algorithms don't seem to have this problem. The relevant 'OUTPUT' parameter gets set to a file path

eg a SAGA algorithm >>> resultConv = processing.run("saga:convergenceindex",{ 'ELEVATION' : resultBreach['OUTPUT'], 'METHOD' : 0, 'NEIGHBOURS' : 1, 'RESULT' : 'TEMPORARY_OUTPUT' }) >>> resultConv['RESULT'] 'C:/Users/brennant/AppData/Local/Temp/processing_KQlbkG/b8b18a166002452898547dfc8e2f5a3c/RESULT.sdat'

Interestingly, for GRASS at least, a temporary file is actually created in the temporary folder. There just doesn't seem to be a way of accessing it via PyQGIS. I assume this is an issue with the way GRASS and WhiteBox Tools are integrated into QGIS

wilhelmberg commented 3 years ago

Came across the same issue.

Simple model:

image

If I run it from the Model Designer it works:

image

Click on Export as Script Algorithm... in the Model Designer and run it from the editor that pops up:

image

wilhelmberg commented 3 years ago

Not sure if this is the right way to do it, but it works for me and might be helpful for others as well.

With these changes to the code generated by Export as Script Algorithm... grass7:v.net.iso produces a TMP_OUTPUT.gpkg in /tmp which can be consumed by qgis:importintopostgis:

    def initAlgorithm(self, config=None):
        self.addParameter(
            QgsProcessingParameterVectorDestination(
                'TMP_OUTPUT'
                , "gpkg-tmp"
            )
        )

    def processAlgorithm(self, parameters, context, model_feedback):

        iso_output = self.parameterAsOutputLayer(parameters, 'TMP_OUTPUT', context)

        # v.net.iso
        alg_params = {
            'output': iso_output
        }
        outputs['Vnetiso'] = processing.run('grass7:v.net.iso', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

        # Export to PostgreSQL
        alg_params = {
            'INPUT': outputs['Vnetiso']['output'],
        }
        outputs['ExportToPostgresql'] = processing.run('qgis:importintopostgis', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

I then call my algorithm like this:

processing.run('<provider_id>:<algo_id>', {'TMP_OUTPUT': QgsProcessing.TEMPORARY_OUTPUT})
wmeinolf commented 3 years ago

@BergWerkGIS , thanks for your contribution. Your suggestion helpes me also for GRASS alg v.net as workaround. I also can confirm, that v.net result is: output;'TEMPORARY_OUTPUT', whereby v.clean returns a Path to my local drive.

land-scapes commented 2 years ago

This unfortunately is still not fixed (v.net) as of QGIS 3.28. Is there a known workaround that works with the model designer without needing to modify python?

marcusyoung commented 1 year ago

Still not fixed in QGIS 3.32.3

wmeinolf commented 11 months ago

In LTR 3.28.13 unfortunately even the workaround does not work anymore :-(

CharlotteFlasse commented 10 months ago

Hi,

QGIS is unable to produce a correct output when using the GRASS tool v.net for both cases – when saving to a temporary output (result – no output is produced) AND when saving to a specific file (output file is produced but is empty).

In the log files (attached to this message) we find the following error, which has also been mentioned here (#26024): DBMI-SQLite erreur de pilote : Unable to create table: error_defineLayer.txt error_temporaryLayer.txt

The issue exists for v.net (and other v.net related tools) and v.clean - Other GRASS tools in QGIS are working fine (such as v.buffer).

OS : Linux Mint 21.2 on base Ubuntu 20.04

Software versions : • QGIS LTR 3.28.11 • GRASS 8.3.1 • libqgisgrass8-3.28.11 • qgis-plugin-grass 3.28.11

For information, on another laptop with the same installation and same environment (OS + software versions), the tools such as v.net work correctly - see example of command output of v.net with the same data : vnet_output_works.txt

AlisterH commented 6 months ago

Hi,

QGIS is unable to produce a correct output when using the GRASS tool v.net for both cases – when saving to a temporary output (result – no output is produced) AND when saving to a specific file (output file is produced but is empty).

In the log files (attached to this message) we find the following error, which has also been mentioned here (#26024): DBMI-SQLite erreur de pilote : Unable to create table: error_defineLayer.txt error_temporaryLayer.txt

The issue exists for v.net (and other v.net related tools) and v.clean - Other GRASS tools in QGIS are working fine (such as v.buffer).

OS : Linux Mint 21.2 on base Ubuntu 20.04

Software versions : • QGIS LTR 3.28.11 • GRASS 8.3.1 • libqgisgrass8-3.28.11 • qgis-plugin-grass 3.28.11

For information, on another laptop with the same installation and same environment (OS + software versions), the tools such as v.net work correctly - see example of command output of v.net with the same data : vnet_output_works.txt

So does it work if you create a new QGIS profile? Or alternatively does it fail on the other laptop if you create a new QGIS profile? Perhaps you have different settings for the GRASS provider on the two computers (e.g. v.external enabled on one).

wmeinolf commented 6 months ago

So does it work if you create a new QGIS profile? Or alternatively does it fail on the other laptop if you create a new QGIS profile? Perhaps you have different settings for the GRASS provider on the two computers (e.g. v.external enabled on one).

Hi and thanks for the question and hint. I checked on both, Windows and Ubuntu VM. v-net connect works, as soon as v.external is NOT set (tickbox empty). Issue can be reproduced, as soon as tickbox fot v.external is set (both, Windows and Ubuntu).

However, this is true for the workaround mentioned by user wilhelmsberg on Sept. 27,2001. It does not solve the issue if QgsProcessing.TEMPORARY_OUTPUT is used.

I am happy for the first real progress since I opened this case more than three yearsa ago. Thanks!

AlisterH commented 6 months ago

From a quick search I think that you could easily disable the use of v.external in any algorithm that it causes to fail. By copying the processInputs code for v.voronoi: https://github.com/qgis/QGIS/blob/dd01d113e3369cc3e659caa4a89bf45e27a6a82f/python/plugins/grassprovider/ext/v_voronoi.py#L27-29 But I don't use v.voronoi, or these algorithms, and I'm afraid I don't have the time to test any of them... unless someone wants to provide some test data so I don't have to learn to use them. Does anybody have any idea if this is the right solution? Or how many grass algorithms. currently fail with v.external?

wmeinolf commented 6 months ago

Hi, I observed this with v.net (connect) and v.clean only. Back in 2021 I also used v.net.steiner.

gregmohler commented 5 months ago

During today's efforts to defeat the dangles, v.clean would not create output in GPKG format. Both in-memory and save-to-disk failed to create a layer with results. Saving to disk did create a .gpkg, but with no layers. Changing the path to end with ".shp" worked fine.

Failing GPKG attempts have this error:
ERROR 1: Wrong field type for fid ERROR: Unable to create column <fid>

Adding a layer creation option to change the FID column in the plugin window allowed the GPKG format to work for both in-memory and to disk. lco="FID=ogc_fid"

Qgis info

Edit - the layer I was using as input already had a int field "fid" and that was causing my issue, most likely an AUTOGENERATE value trying to be put into the int column. 🤦