1

I'm create a python script tool in QGIS that is working perfect. However when I use the "Selected features only" checkbox to run my script in just one polygon feature it returns the following error:

Could not load source layer for INPUT: invalid value

Here in how I'm initiating the variable in initAlgorithm and processAlgorithm functions:

def initAlgorithm(self, config=None):
    self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT_POL,
                self.tr('Property Polygon'),
                [QgsProcessing.TypeVectorPolygon]
            )
        )
        
def processAlgorithm(self, parameters, context, feedback):
    shp_roi = self.parameterAsSource(parameters, self.INPUT_POL, context)

How could I overcome this issue?

2
  • Code seems absolutely correct. Does this issue repeat on different data sourses or layers?
    – RainForest
    Commented Mar 9, 2023 at 18:38
  • Could you provide a minimal working example? Commented Mar 11, 2023 at 12:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.