TransWikia.com

Applying custom plugins using PyQGIS script

Geographic Information Systems Asked by nasser tahani on February 13, 2021

I’ve downloaded the select within plugin to select features inside polygons objects. I’ve imported the plugin using import SelectWithin as sw in the console but QGIS does not suggest any of its methods to use.

How can I apply this plugin to my script using PyQGIS and is it possible to use the functions of this plugin in the script?

One Answer

You can show Select Within window using this script:

from SelectWithin.select_within import SelectWithin

# 1st SelectWithin is plugin name, 2nd select_within is module/file name,
# 3rd SelectWithin is class name within the select_within.py file

sw = SelectWithin(iface)
sw.run()

enter image description here

Also, you can use count_vertices, create_centroids, centroid_point, dissolve_feats methods with varible sw, but cannot run processes which OK button does, without displaying Select Within window. Because many of processes are called in run method, and that method always displays the window.

If you want to use all functionality of the plugin, you need to change the contents of select_within.py file (especially run method).

Correct answer by Kadir Şahbaz on February 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP