[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.

Hi

you have to call QgsApplication.setPrefixPath() prior to call to
initQgis(). It is covered here:
http://www.qgis.org/pyqgis-cookbook/intro.html#using-pyqgis-in-custom-application

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

Regards
Martin


More information about the Qgis-developer mailing list