[Qgis-user] getFeatures() and fields()

Roberto Herrero apabardexu at gmail.com
Tue Oct 30 01:39:22 PDT 2018


You are right, Nyall. The problem was the path of the vector layer.

Thank you,
Roberto

El lun., 29 oct. 2018 a las 23:54, Nyall Dawson (<nyall.dawson at gmail.com>)
escribió:

> On Tue, 30 Oct 2018 at 06:39, Roberto Herrero <apabardexu at gmail.com>
> wrote:
> >
> > getFeatures() and fields() do not seem to work in Qgis3.2
>
> They 100% work -- if they didn't, QGIS wouldn't be good for anything
> except wasting some space on your computer ;)
>
> > # Open vector layer
> > LayerName = u'Vector_layer.shp'
> > VectorLayer = qgis.core.QgsVectorLayer(LayerName, 'mylayer', 'ogr')
>
> I suspect this is where the issue sits -- try checking
>
> assert VectorLayer.isValid()
>
> here. My suspicion is that your relative path 'Vector_layer.shp' is
> not working, and will need to be an absolute path.
>
> Nyall
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20181030/900ae6b9/attachment.html>


More information about the Qgis-user mailing list