Geographic Information Systems Asked on May 17, 2021
I have a Python script that I have exported from a QGIS model and I want to specify the layer it creates as output.
If defaultValue=None
it outputs 'Reportpmbc'
: 'Centroids_9c779c9c_4bcc_471b_971e_fbea3bb27c7d'
, in the log window and a 'Centroids'
layer is created in the project.
I want it to create a temporary layer 'Report-PMBC'
as below but it won’t run. (“.” files are not supported as outputs for this algorithm)
What am I missing in the statement below? I think I have to create a temporary layer in memory and write to it but I am not sure how to do that.
self.addParameter(QgsProcessingParameterFeatureSink('Reportpmbc', 'Report-PMBC', type=QgsProcessing.TypeVectorPoint, createByDefault=True, defaultValue='Report-PMBC'))
Create the variable Report-PMBC in your algorithm like this:
class YourAlg(QgsProcessingAlgorithm):
Report_PMBC = 'Report-PMBC'
Add the parameter like this in you initAlgorithm method:
self.addParameter(QgsProcessingParameterFeatureSink(
self.Report-PMBC,
'Report-PMBC',
QgsProcessing.TypeVectorPoint))
Answered by lcoandrade on May 17, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP