[Qgis-user] Get layer-id by layer (not by acive layer)

Nathan Woodrow madmanwoo at gmail.com
Mon Oct 13 04:54:11 PDT 2014


layer.id() returns the id

http://qgis.org/api/classQgsMapLayer.html#a710f27dec806d3bcd5ae14701c2e6fd7

layer.name() returns the name

http://qgis.org/api/classQgsMapLayer.html#aff7fb3990b6c736fbe41643666b027e5

If you have a layerid and you want to look up the layer object for it you
can use:

QgsMapLayerRegistry.instance().mapLayers[layerid]

if you have a name and would like the layers objects:

maplayers = QgsMapLayersRegistry.instance().mapLayersByName(name)



On Mon, Oct 13, 2014 at 9:38 PM, walter.nordmann <walter.nordmann at web.de>
wrote:

> Nathan Woodrow wrote
> > Try this:
> >
> > maplayers = QgsMapLayerRegistry.instance().mapLayers()
> >
> > maplayers will be a dict of layerid-layer object
>
> and than? i'm new to qgis programming and the documentation is not very
> helpfull :(
>
> Please no breadcrombs. Trying to solve this little problem for 2 day now :(
>
> should be something like layer.getId() but i can't find it.
>
> Regards
> walter
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/Get-layer-id-by-layer-not-by-acive-layer-tp5167152p5167195.html
> Sent from the Quantum GIS - User mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141013/c099d340/attachment.html>


More information about the Qgis-user mailing list