[Qgis-user] Invalid data source loading vector layer using PyQGIS
Mathieu Coudert
mathieu.coudert at gmail.com
Fri Apr 22 07:40:43 PDT 2011
Hi list,
I'm trying to load a vector layer (shapefile) using PyQGIS and especially
QgsVectorLayer constructor.
I had a look at the following link to start with :
http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications
and also :
http://www.qgis.org/pyqgis-cookbook/loadlayer.html#vector-layers
So my script looks like :
*QgsApplication.setPrefixPath("/usr",True)*
*QgsApplication.initQgis()*
*myLayer = QgsVectorLayer("/tmp/data.gboundaries.shp","gboundaries","ogr")*
But I get this error message : "Data source is invalid" and my layer is
invalid.
However, it is working when I launch it in the QGIS python console.
Do I need to set/export any variable outside of QGIS to use the ogr
provider?
Does anybody has any clue about my problem?
FYI, I'm working on Ubuntu 10.10, with Python 2.6 and QGIS 1.6 (from the
packages).
Thanks for your help,
Cheers,
Mathieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20110422/47b24916/attachment.html>
More information about the Qgis-user
mailing list