[Qgis-developer] Problem using vector data provider in python
Martin Dobias
wonder.sk at gmail.com
Tue Dec 14 15:49:11 EST 2010
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
More information about the Qgis-developer
mailing list