[Qgis-user] QGIS 3 Processing question

Nyall Dawson nyall.dawson at gmail.com
Mon Jul 2 16:36:42 PDT 2018


On Fri, 29 Jun 2018 at 17:35, Frank Broniewski
<hallo at frankbroniewski.com> wrote:

>     def processAlgorithm(self, parameters, context, feedback):
>         # qgis:pointsalonglines
>         params = {
>             'INPUT': parameters[self.INPUT],
>             'DISTANCE': parameters[self.DISTANCE],
>             'START_OFFSET': 0,
>             'END_OFFSET': 0,
>             'OUTPUT': 'memory:'
>         }
>         points = processing.run(
>             'qgis:pointsalonglines',
>             params, context=context, feedback=feedback
>         )['OUTPUT']
>
>         return {self.OUTPUT: points}
>

Try:

     def processAlgorithm(self, parameters, context, feedback):
         # qgis:pointsalonglines
         params = {
             'INPUT': parameters[self.INPUT],
             'DISTANCE': parameters[self.DISTANCE],
             'START_OFFSET': 0,
             'END_OFFSET': 0,
             'OUTPUT': 'memory:'
         }
         points = processing.run(
             'qgis:pointsalonglines',
             params, context=context, feedback=feedback
         )['OUTPUT']

        # store result layer in context - this prevents it being
deleted and cleaned up
        # when processAlgorithm finishes
        context.temporaryLayerStore().addMapLayer(points)

         # return the layer ID in the results dictionary - processing
will automatically retrieve the corresponding
         # layer from the context when required
         return {self.OUTPUT: points.id()}


Nyall



More information about the Qgis-user mailing list