Is it possible to reach the Spatial Query plugin functionality in QGIS from a Python script (PyQGIS)? If so, how do I accomplish this? Haven't found any documentation for it, even in the C++ API docs...
Regards, Andreas
|
|
Yes, you can access plugin functions from a Python script e.g. to access fTools try in the QGIS Python console:
or more generic for other plugins:
|
|||
|
|
|
You can write your own function in Python easily enough using one of the many excellent Python APIs available. Have a look at GDAL/OGR. The documentation is focussed on C++ but you should be able to understand it enough to figure out the Pythonic equivalent. A great tutorial on this can be found here. Alternatively try 'Shapely'. If you are comfortable with databases have a look at PostGIS or SpatiaLite. All of these have Python API that will allow you to construct your own queries for all the spatial queries that you can find in QGIS or ArcGIS or almost any GIS. To get started I recommend going through the tutorial for GDAL/OGR above and then branching out. |
|||
|
|
|
It is not possible to get access to the spatial query plugin, because it is a C++ plugin without python bindings. For python plugins in contrast, it is possible to import other plugin's interfaces by using the method outlined by webrian
You can also get access to loaded and instantiated plugins by using
In this case, the best shot is to write logic based on existing libraries as outlined by MappaGnosis. |
|||
|
|