1

Using the QGIS 3.x processing framework, given a vector layer as an input parameter:

(from the default script template)

def initAlgorithm(self, config=None):
    self.addParameter(
        QgsProcessingParameterFeatureSource(
            self.INPUT,
            self.tr('Input layer'),
            [QgsProcessing.TypeVectorAnyGeometry]
        )
    )

How can I get this layer's source file path as a string? (assume that only file-based data sources will be used, not PostGIS tables, etc.)

2

I was able to get the path using the following:

self.parameterDefinition('INPUT').valueAsPythonString(parameters['INPUT'], context)

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.