[Qgis-developer] Basic question: How to select a layer in the GUI and get the handle in the Python code?

Ole Nielsen ole.moller.nielsen at gmail.com
Sun Dec 11 23:16:49 EST 2011


Thanks for your help. Using QgsVectorLayer worked straight away to give the
handle from the source files.
I assume OgsRasterLayer will work the same way. I can use the file name
extension to determine if the file is raster or vector but was wondering if
Qgis has a library for that too?

Cheers and thanks
Ole



On Fri, Dec 9, 2011 at 6:45 PM, Alexander Bruy <alexander.bruy at gmail.com>wrote:

> Hi Ole,
>
> 2011/12/9 Ole Nielsen <ole.moller.nielsen at gmail.com>:
> > With that loaded layer names show up in the combo and after selection the
> > fully qualified filename is returned by layer.source()
> >
> > However, if I want a handle to an active layer, like I got
> > with self.iface.mapCanvas().currentLayer() is there any way that could be
> > obtained from the layer object?
>
> as I see you use code from Giuseppe. If you want to get
> layer object use my function or modify your existing code.
> You need to create a QgsVectorLayer object from layer's
> source.
>
> --
> Alexander Bruy
> NextGIS
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20111212/6b3b8473/attachment.html


More information about the Qgis-developer mailing list