[Qgis-developer] Problem using vector data provider in python

Chris Crook ccrook at linz.govt.nz
Tue Dec 14 15:57:34 EST 2010


Thanks Martin

Good point .. There really isn't any reason not to create a QgsVectorLayer.  I was failing to distinguish between map layers that are displayed, and QgsVectorLayer, which isn't

Many thanks
Chris

-----Original Message-----
From: Martin Dobias [mailto:wonder.sk at gmail.com] 
Sent: Wednesday, 15 December 2010 9:49 a.m.
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Problem using vector data provider in python

On Tue, Dec 14, 2010 at 9:18 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi All
>
> I'm wondering if it is possible to use a QgsVectorDataProvider independently from a map layer in Python.  For example, I'd like to open a GML file and read features, etc from it without creating a map layer.
>
> I can get as far as
>
> p=QgsProviderRegistry.instance().getProvider("ogr","myfile.gml")
>
> But what I get back is QgsDataProvider.
>
> <qgis.core.QgsDataProvider object at 0x099BE6F0>
>
> So all the QgsVectorDataProvider methods don't seem to be available.

Hi Chris

there was a missing conversion routine that would tell python that a subclass exists. I've added it to trunk in r14911, so now you should get QgsVectorDataProvider instance.

While instantiating a vector data provider without its QgsVectorLayer counterpart is possible, IMO it's more convenient to use the latter (and there's barely any overhead).

Regards
Martin
______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________


More information about the Qgis-developer mailing list