[Qgis-user] Python scripting

Alex Mandel tech_dev at wildintellect.com
Thu Apr 2 16:08:33 EDT 2009

georgew wrote:
> georgew wrote:
>> Hi all, I have not been able to find an answer to this question: Using the latest stable version of QGIS from OSGeo4W on WinXP SP3 is it possible to write free standing Python programs/scripts that will access QGIS objects (vectors, shapefiles, etc) and process them in batch, without the need for GUI or user intervention other than to run the script from Python command line (or within an IDE)?
> It should be possible, I believe OSGeo4w installs it's own python and
> hence all python libraries would be on it's path not on your system
> installed python.
> To use the libraries with your regular python install you probably need
> to and to the PYTHONPATH environment variable of your system the path to
>   something like C:\OSGEO4W\QGIS\
> Then import qgis.core and such should work.
> Alex
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
> ThanKs Alex, the problem is I have not been able to find any example that is free standing, all seem to be plugins or use QT to generate a UI. Can you point me to a working example, however simple (e.g. read shapefile, project,write shapefile) that can set me off on the right path?
> Many thanks
> G.

Sorry, I don't have an example. But python is much more flexible than
you a giving it credit for. All of the plugins will work as examples for
you, just ignore the parts of the code that involve the UI.

In python if you
import qgis.core
and then start writing code that uses functions from the core it will
just work.


More information about the Qgis-user mailing list