4

I don't understand why if I do "manually" some algorithms I get results much faster than when I insert the same in a pyqgis code (with the same input). This happens, for example, with the extract nodes algorithm. I wrote a code in which I call the algorithm as follows:

p=processing.runalg('qgis:extractnodes', polylayer, None)

points = processing.getObject(p['OUTPUT']) 

The whole process slows down considerably during the execution of this algorithm (which appears on the top bar, so I am sure that the problem is right on the extract nodes), taking about an hour for provide a result that I would normally be able to achieve in a few seconds.

  • which version of Qgis are you using? I had this general issue with Qgis 2.18. I'm not sure whether it is still valid for Qgis3.0. – Kantan Jun 6 '18 at 7:39
  • 1
    Also you might want to take a look at this, about code optimisation : nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts (Though here it doesn't seem to be related to your issue) – Kantan Jun 6 '18 at 7:45
  • I'm using Qgis 2.18 too. Do you think could be a problem? Thanks for the link: it's not related to my issue directly but it is useful for the future! – Sara Gaudio Jun 6 '18 at 9:38
  • It might, I think there was a bug report about that a few month ago. You might want to look for it, or maybe try it on Qgis 3.0 to see if it's been addressed! – Kantan Jun 6 '18 at 14:46
  • @Kantan the problem is that if I want use Qgis 3.0 I should change every part of my python code because the new version uses Qt5 and Python 3.x while the last version used Qt4 and Python 2.7 – Sara Gaudio Jun 8 '18 at 9:58

Your Answer

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

Browse other questions tagged or ask your own question.