[Qgis-developer] vector layers loaded using pyQGIS not isValid()

Martin Dobias wonder.sk at gmail.com
Mon Apr 4 07:20:52 EDT 2011

On Mon, Apr 4, 2011 at 1:10 PM, Marco Lechner - FOSSGIS e.V.
<marco.lechner at fossgis.de> wrote:
> Hi,
> I'm trying to load several vector layers (shp and spatialite) using
> PyQGIS but the Layers are never valid. what am I doing wrong? According
> to http://www.qgis.org/pyqgis-cookbook/loadlayer.html it should be al
> right. The used shape can be regularly opened from QGIS without any
> problems. Opening geotiffs works without problems.


you have to call QgsApplication.setPrefixPath() prior to call to
initQgis(). It is covered here:

Otherwise it fails to find data providers and thus it's impossible to
load layers.


More information about the Qgis-developer mailing list