[Qgis-developer] qgis+python bindings: failed to load vector layer

Martin Dobias wonder.sk at gmail.com
Sun Aug 5 10:47:07 EDT 2007


you've pasted only a small snippet of code, so I can't say what's
wrong just from it. But I would guess that you're either not calling
initQgis() (which loads vector providers) or you set invalid path to
qgis in setPrefixPath()

If this is not your case, please provide the whole source file.

On 7/24/07, Luca Mandolesi <mandoluca at gmail.com> wrote:
> Hi to alls!
> I've installed qgis svn under Mac OS X 10.4 and I've tried to use the
> tutorial by Martin Dobias.
> I can view the evry raster images but if I try to load a vector layer
> I recive tis message:
> Failed to load
> I think the problem is in this point of my code,
>     layerPath =  "/Users/heywood/Desktop/shape_dir/shapefile.shp"
>     layerName = "shapefile"
>     layerProvider = "ogr"
>     # create layer
>     layer = QgsVectorLayer(layerPath, layerName, layerProvider)
>     if not layer.isValid():
>       return
> but I don't understand where is the mystake and beacause the layer
> isn't valid. The problm can be the path, the layer name or the
> provider?
> thanks a lot
> bye bye
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer

More information about the Qgis-developer mailing list