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

Marco Lechner - FOSSGIS e.V. marco.lechner at fossgis.de
Mon Apr 4 07:45:40 EDT 2011

Am 04.04.2011 13:20, schrieb Martin Dobias:
> 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
so this is
QgsApplication.setPrefixPath("/usr/", True)



But why did it work for the geotif?


More information about the Qgis-developer mailing list