Open wmeinolf opened 3 years ago
I have no idea, why the "Won't fix" Lable has been added!
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
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.
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
--------------------------------------- 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 ############################################
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..100g.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..100Erstelle 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
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
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
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
Came across the same issue.
Simple model:
If I run it from the Model Designer it works:
Click on Export as Script Algorithm...
in the Model Designer and run it from the editor that pops up:
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})
@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.
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?
Still not fixed in QGIS 3.32.3
In LTR 3.28.13 unfortunately even the workaround does not work anymore :-(
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
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).
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!
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?
Hi, I observed this with v.net (connect) and v.clean only. Back in 2021 I also used v.net.steiner.
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. 🤦
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):
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