Hi all,
I am getting my feet wet with the new QGIS 3 Processing script syntax. In my script I want to use some other processing scripts from the toolbox. I think I got most things right, but I do not get a result back. For testing I just try to use qgis:pointsalonglines on a temporary polygon layer and return the points as a result. Heres what I have so far: def initAlgorithm(self, config=None): self.addParameter( QgsProcessingParameterFeatureSource( self.INPUT, self.tr("Vector Polygon Layer"), [QgsProcessing.TypeVectorPolygon] ) ) [ ] self.addParameter( QgsProcessingParameterFeatureSink( self.OUTPUT, self.tr('Center line'), QgsProcessing.TypeVectorAnyGeometry ) ) def processAlgorithm(self, parameters, context, feedback): source = self.parameterAsSource(parameters, self.INPUT, context) # turn QgsProcessingParameterFeature - the source - into a # QgsVectorLayer apparently self.parameterAsVectorLayer() does # not work on temporary layers so this step is required to use # the input layer in processing algorithms source_vl = source.materialize(QgsFeatureRequest()) pt_value = [ ] # qgis:pointsalonglines params = { 'INPUT': source_vl, 'DISTANCE': pt_value, 'START_OFFSET': 0, 'END_OFFSET': 0, 'OUTPUT': 'memory:' } points = processing.run( 'qgis:pointsalonglines', params, context=context, feedback=feedback )['OUTPUT'] return {self.OUTPUT: points} running the script gives the following output in the processing window (including some debug info not included above): Eingabeparameter: { 'DISTANCE' : 10, 'INPUT' : 'Polygon?crs=EPSG:31466&uid={e1a2d6cf-0cac-46f5-b1c8-ee208c497d22}', 'OUTPUT' : 'memory:' } <class 'qgis._core.QgsProcessingFeatureSource'> Ergebnisse: {'OUTPUT': 'output_953bb179_3f12_4312_89e4_5ffa13e8336b'} <class 'qgis._core.QgsVectorLayer'> Ausführung nach 0.03 Sekunden abgeschlossen Ergebisse: {'OUTPUT': <PyQt5.QtCore.QObject object at 0x0000023FC2CEBC18>} Lade Ergebnis Layer Algorithmus 'None' beendet The last output line does not look right to me, any idea what I am doing wrong here? Many thanks, Frank Dipl. Geogr. Frank Broniewski Waldhölzbacher Str. 51 66679 Losheim am See 06872 509 068 4 0176 611 26 9 2 6 <http://www.frankbroniewski.com> www.frankbroniewski.com
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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