0

I am writing a Processing Algorithm based on this template. Can I populate the QgsProcessingParameterFeatureSink from a delimitedtext provider in a similar fashion to the iface.addVectorLayer() (i.e. the following code snippet) ?

uri = ('file:///{}?'
       'type=regexp'
       '&delimiter={}'
       '&skipLines={}'
       '&useHeader=No'
       '&trimFields=Yes'
       '&xField=field_11'
       '&yField=field_12'
       '&crs={}'
       '&spatialIndex=Yes'
       '&subsetIndex=no'
       '&watchFile=Yes').format(myFile,
                                myRe,
                                countSkips(myFile),
                                myCrs)

layer = iface.addVectorLayer(uri, 'MY LAYER',  'delimitedtext')
1

You don't need to use feature sink parameters for a hard-coded layer like this. Just load it direct via

vl=QgsVectorLayer(uri, 'MY LAYER',  'delimitedtext')
  • Thanks, so based on the mentioned template, how should I define my output? QgsVectorLayer directly? – YeO Apr 22 '18 at 2:51
  • I've tried to define my output as QgsProcessingParameterVectorDestination (rather than QgsProcessingParameterVectorLayer) then set vl = self.parameterAsVectorLayer(parameters, self.OUTPUT, context) but I can't make it work. – YeO Apr 22 '18 at 5:27
  • I've made it a new question as my problem is now how to get my Algorithm return this vl. – YeO Apr 28 '18 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.