-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities.py
31 lines (24 loc) · 995 Bytes
/
utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
# ================================================================
# author :Ghislain Vieilledent
# email :ghislain.vieilledent@cirad.fr
# web :https://ecology.ghislainv.fr
# python_version :>=3.6
# license :GPLv3
# ================================================================
"""Useful functions."""
def add_layer(project, layer):
"""Add layer after removal if its name exists."""
for lay in project.mapLayers().values():
if lay.name() == layer.name():
project.removeMapLayers([lay.id()])
project.addMapLayer(layer, False)
project.layerTreeRoot().addLayer(layer)
def add_layer_to_group(project, group, layer):
"""Add layer to group after removal if its name exists."""
for lay in project.mapLayers().values():
if lay.name() == layer.name():
project.removeMapLayers([lay.id()])
project.addMapLayer(layer, False)
group.addLayer(layer)
# End of file