[Qgis-developer] Problem loading Vector Layer

Jitendra kumar jitendra.harlalka at gmail.com
Tue Oct 26 01:11:47 EDT 2010


On Tue, Oct 26, 2010 at 3:22 AM, Martin Dobias <wonder.sk at gmail.com> wrote:

> On Tue, Oct 19, 2010 at 4:45 PM, Jitendra kumar
> <jitendra.harlalka at gmail.com> wrote:
> > Hello all,
> >     I am new to Python binding for QGIS. I have been having problem in
> > getting a Vector Layer to be loaded. I typed the following on python
> > console:
> >
> >>>> from qgis.core import *
> >>>> layer=QgsVectorLayer("/path/to/shape/file.shp","layer","ogr")
> > Failed to load
> >
> > The output is "Failed to load" which isn't very helpful and doesn't
> specify
> > the cause. I am not sure what is the problem. I have confirmed that
> filepath
> > is correct and the shp file can be opened in QGIS. I would appreciate if
> > someone could help me solve the problem.
>
> Are you using python console within QGIS or do you open the python
> interpreter from a terminal? In the latter case, you would have to
> initialize qgis core library first by calling
> QgsApplication.initQgis() otherwise it will not find the data
> providers necessary for opening vector layers.
>

@Martin,
I am glad you replied. I was actually using python interpreter from
terminal. And, now I understand why I couldn't get it to work. It works fine
now.

It would be great if someone could make the error message more helpful.
"Failed to load" wasn't very helpful ;)

Thanks once again.

Regards,
Jitendra

http://www.qgis.org/pyqgis-cookbook/intro.html#using-pyqgis-in-custom-application
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20101026/7606e019/attachment.html


More information about the Qgis-developer mailing list