[Qgis-developer] Point sampling tool and python console

Martin Dobias wonder.sk at gmail.com
Tue May 22 11:55:00 PDT 2012


Hi Xavier

On Sun, May 20, 2012 at 8:10 PM, Xavier Vollenweider
<x.y.b.vollenweider at googlemail.com> wrote:
> Hi all,
>
> I am new to QGIS and to Python.
>
> I would like to use the plugin point sampling tool in order to merge raster
> datasets with my observations (a delimited text layer) and then save the
> resulting shape file as a csv file. I know how to do it with the GUI:
>
> Add Delimited Text Layer
> Add Raster Layer
> Point Sampling Tool
> Join the layer
> Save as .csv
>
> As I have quite a lot of raster dataset to match with my observations (and I
> am quite keen to learn Python), I would like to do it with a loop in the
> Python console.

Right now most of the plugins are not prepared to be used from a
console (or from a script) because many times their algorithms are
bound to GUI. But in case some plugins are well-written with separated
GUI from logic, you could use them - it is possible to access plugins
from console - this will show a dictionary with plugin names and
instances:
>>> qgis.utils.plugins
(There are even methods for loading and unloading python plugins)

So to call a plugin's routine, you would do something like this:
>>> qgis.utils.plugins['super_plugin'].do_something( my_data )

Another option is to look at the plugin that has the functionality you
need and use the some pieces of code directly in your script.

Yet another option seems to be SEXTANTE - a plugin that brings a
common interface for algorithms. It should also allow you to run
algorithms from batch script.

Martin


More information about the Qgis-developer mailing list