Re: [Qgis-user] Processing: QGIS Crash with new processing script format, QGIS 3.6.1-SOLVED
Hi Harvard, that's on the point - it works perfect now. Just in time, that I can use it next monday in my PYQGIS workshop. I think, that is tons easier to understand then the whole bunch of functions which you had to define before. Thank's again for the link and the work done on the manual. I have attached the changed script with the two processing algorithms 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.gi...@wheregroup.com www.wheregroup.com Amtsgericht Bonn, HRA 6788 --- Komplementärin: WhereGroup Verwaltungs GmbH vertreten durch: Olaf Knopp, Peter Stamm --- Am 2019-04-12 08:50, schrieb Havard Tveite: Hi Stefan, We have recently updated the user manual to reflect this new great feature. Can you test the example that is given there (also includes two processing algorithms)? https://docs.qgis.org/testing/en/docs/user_manual/processing/scripts.html#the-alg-decorator Håvard On 12.04.2019 08:28, Stefan Giese wrote: 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 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user 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.VECTOR_LAYER_DEST, name='BUFFER_OUTPUT', label='Buffer output') def centroids_and_buffer(instance, parameters, context, feedback, inputs): """ Description goes here. (Don't delete this! Removing this comment will cause errors.) """ source = instance.parameterAsVectorLayer(parameters, "INPUT", context) if feedback.isCanceled(): return {} centroids = processing.run("native:centroids", {'INPUT': parameters['INPUT'], 'ALL_PARTS': True, 'OUTPUT': 'memory:'}, is_child_algorithm=True, context=context, feedback=feedback) if feedback.isCanceled(): return {} alg_params = {'DISSOLVE': False, 'DISTANCE': 0.01, 'END_CAP_STYLE': 0, 'INPUT': centroids['OUTPUT'], 'JOIN_STYLE': 0, 'MITER_LIMIT': 2, 'SEGMENTS': 5, 'OUTPUT': parameters['BUFFER_OUTPUT']} buffer = processing.run("native:buffer", alg_params, is_child_algorithm=True, context=context, feedback=feedback) if feedback.isCanceled(): return {} return {'BUFFER_OUTPUT': buffer['OUTPUT']}___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Processing: QGIS Crash with new processing script format, QGIS 3.6.1
Hi Havard, thanks a lot, yes I will test it and send you my feedback within the next days. 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.gi...@wheregroup.com www.wheregroup.com Amtsgericht Bonn, HRA 6788 --- Komplementärin: WhereGroup Verwaltungs GmbH vertreten durch: Olaf Knopp, Peter Stamm --- Am 2019-04-12 08:50, schrieb Havard Tveite: Hi Stefan, We have recently updated the user manual to reflect this new great feature. Can you test the example that is given there (also includes two processing algorithms)? https://docs.qgis.org/testing/en/docs/user_manual/processing/scripts.html#the-alg-decorator Håvard On 12.04.2019 08:28, Stefan Giese wrote: 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 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Processing: QGIS Crash with new processing script format, QGIS 3.6.1
Hi Stefan, We have recently updated the user manual to reflect this new great feature. Can you test the example that is given there (also includes two processing algorithms)? https://docs.qgis.org/testing/en/docs/user_manual/processing/scripts.html#the-alg-decorator Håvard On 12.04.2019 08:28, Stefan Giese wrote: 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 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user -- Håvard Tveite Faculty of Science and Technology, NMBU Drøbakveien 31, POBox 5003, N-1432 Ås, NORWAY Phone: +47 67231548 Web: http://www.nmbu.no ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] Processing: QGIS Crash with new processing script format, QGIS 3.6.1
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.gi...@wheregroup.com www.wheregroup.com Amtsgericht Bonn, HRA 6788 --- Komplementärin: WhereGroup Verwaltungs GmbH vertreten durch: Olaf Knopp, Peter Stamm --- 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']}___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user