Get the current layer
Often, you'll have to perform operations on the active layer.
Before performing these operations, you first have to identify it and get it.
Once you have it, you can perform all the operations you'll want.
In the following lines, i've included print statements so as to check the content of my variables.
>>> print mycurrentlayer.getLayerID()
>>> print mycurrentlayer.name()
Firts of all, put the canvas in the variable mc.
Once you have your canvas, get its current layer called mycurrentlayer.
You can see some methods have been applied to the layer:
- the method getLayerID()
- the method name()
The layer id is often used whe performing operations on the layer.
Get a layer according according to its position in the legend
The method getZpos allows you to get a layer according to its position in the legend.
This kind of routine is often used when you need to get layers with their indexes