[Qgis-user] Processing: QGIS Crash with new processing script format, QGIS 3.6.1

Stefan Giese Stefan.Giese at wheregroup.com
Thu Apr 11 23:28:48 PDT 2019


Hi everybody,

I've just played with the new (3.6.1) processing script format (see 
https://github.com/qgis/QGIS-Enhancement-Proposals/issues/134 or 
https://anitagraser.com/2019/03/02/easy-processing-scripts-comeback-in-qgis-3-6/) 
and tried to put 2 processing algorithmen in it (centroid and buffer), 
but without success. The script stopped with the ":( QGIS crashed" - so 
anything goes wrong I suppose. May be someone can help me to get the 
right idea to connect various processing steps within the new format. my 
script is attached, it should take a polygon layer, make the centroids 
and then buffer the points.

best regards

stefan

-- 
Mit freundlichen Grüßen
Stefan Giese
Projektleiter/Consultant
-----------------------------------
Aufwind durch Wissen!
Qualifizierte Open-Source-Schulungen
bei der www.foss-academy.com
-----------------------------------
WhereGroup GmbH & Co. KG
Schwimmbadstr. 2
79100 Freiburg
Germany

Fon: +49 (0)761 / 519 102 - 61
Fax: +49 (0)761 / 519 102 - 11

stefan.giese at wheregroup.com
www.wheregroup.com
Amtsgericht Bonn, HRA 6788
-------------------------------
Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Olaf Knopp, Peter Stamm
-------------------------------

-------------- next part --------------
from qgis.processing import alg
import processing
@alg(name="centroids_and_buffer", label=alg.tr("Centroids and buffer"), group="examplescripts", group_label=alg.tr("Example Scripts"))
@alg.input(type=alg.SOURCE, name="INPUT", label="Input layer")
@alg.input(type=alg.SINK, name="OUTPUT", label="Output layer")  #output vector layer

def testalg(instance, parameters, context, feedback, inputs):
    """
    Description goes here. (Don't delete this! Removing this comment will cause errors.)
    """
    source = instance.parameterAsVectorLayer(parameters, "INPUT", context)
    output = instance.parameterAsOutputLayer(parameters, "OUTPUT", context)  #not sure if this is correct

    centroids = processing.run("native:centroids", {'INPUT': source,'ALL_PARTS': True, 'OUTPUT': 'memory:'})
    #now the buffer
    alg_params = {'DISSOLVE': False,
        'DISTANCE': 0.001,
        'END_CAP_STYLE': 0,
        'INPUT': centroids['OUTPUT'],
        'JOIN_STYLE': 0,
        'MITER_LIMIT': 2,
        'SEGMENTS': 5,
        'OUTPUT': 'memory:'}
    buffer= processing.run("native:buffer", alg_params)
    print(buffer['OUTPUT'])
    #output = buffer['OUTPUT'] #I've tried both, same crash
    return {"OUTPUT": buffer['OUTPUT']}


More information about the Qgis-user mailing list