I want to count points in polygon, using PyQGIS. When I check the documentation, I find the description of the {parameter_dictionary}, but not the algorithm name which must also be provided.

What is the name of the algorithm which I have to write in here processing.run("algorithm_id", {parameter_dictionary})?


In case you do not know a name or id, you can use:

searchstring = 'count' # to get all algorithms just leave this empty
for alg in QgsApplication.processingRegistry().algorithms():
    if searchstring in alg.id(): 

to search for it. In your case its native:countpointsinpolygon

  • A smart solution when you know what to look for, but what if there are many algorithms that match similar name patterns.
    – Taras
    Oct 1 at 6:06
  • Usually it should be clear by the id which one to choose. If there are several identical, you can identify them by the provider name. Thats just like when searching for a tool in processing toolbox.
    – MrXsquared
    Oct 1 at 12:05

It is "native:countpointsinpolygon".

I usually execute the tools manually in QGIS then Ctrl+Alt+H to copy paste the syntax to use in PyQGIS.

  • 1
    Wonderful approach with Ctrl+Alt+H !
    – Taras
    Oct 1 at 7:44
  • 1
    That has also been my go-to approach for quite some time. It really cuts down on visits to the docs, and a good entryway to scripting with PyQGIS. :)
    – Matt
    Oct 1 at 13:03

Just in case, its documentation is here for the latest QGIS version, otherwise replace the word testing by, e.g. 3.16:


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.