0

I've got the following Code for cutting points by a mask layer:

pointlayer = 'C:/temp/points.shp'
masklayer = 'C:/temp/mask.shp'
outputlayer = 'C:/temp/result.shp'

algo = 'native:clip'
params = {
'INPUT' : pointlayer,
'OUTPUT' : outputlayer,
'OVERLAY' : masklayer
}

import processing
processing.runAndLoadResults(algo, params)

It throws me the following error:

Traceback (most recent call last):
  File "C:\OSGeo4W\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 13, in <module>
  File "C:\OSGeo4W/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 151, in runAndLoadResults
    return Processing.runAlgorithm(alg, parameters=parameters, onFinish=handleAlgorithmResults, feedback=feedback,
  File "C:\OSGeo4W/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 189, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "C:\OSGeo4W/apps/qgis-ltr/./python/plugins\processing\gui\AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Konnte Obekt nicht in OUTPUT schreiben

But if I change the output to a 'TEMPORARY_OUTPUT' it works. Can someone explain why and how to fix this? I need the result in a not-temporary file.

With just processing.run(algo, params) I got the same error!

5
  • What does the error say in English? Commented Jun 27, 2023 at 15:05
  • Its like: Couldnt write object to output
    – fsg
    Commented Jun 27, 2023 at 15:50
  • Does "result.shp" already exist?
    – RainForest
    Commented Jun 28, 2023 at 5:58
  • No, it does not exist. But it is created when i run the script. But it does not have any features in it.
    – fsg
    Commented Jun 28, 2023 at 6:42
  • did you try change the result filename? Commented Jun 28, 2023 at 10:31

1 Answer 1

2

I found a solution with just using another algorithm: saga:clippointswithpolygons

With this algorithm i can store the output without problems.

Your Answer

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

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