forked from LEOXINGU/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_feicoes_duplicadas.py
More file actions
55 lines (51 loc) · 2.15 KB
/
remove_feicoes_duplicadas.py
File metadata and controls
55 lines (51 loc) · 2.15 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
/***************************************************************************
LEOXINGU
-------------------
begin : 2017-10-10
copyright : (C) 2017 by Leandro Franca - Cartographic Engineer
email : geoleandro.franca@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation. *
* *
***************************************************************************/
"""
# Verificar Auto-Intersecao
##LF2) Revisao=group
##06. Remover Feicoes Duplicadas=name
from PyQt4.QtCore import *
from qgis.gui import QgsMessageBar
from qgis.utils import iface
from qgis.core import *
import processing
import time
# Varrer camadas
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
if layer.type()==0:
cont = 0
lista = []
apagar = []
for feat in layer.getFeatures():
geom = feat.geometry()
coord = geom.exportToGeoJSON()
att = feat.attributes()
if [coord, att[1:]] in lista:
apagar += [feat.id()]
cont += 1
else:
lista += [[coord, att[1:]]]
# Apagar feicoes
if apagar:
DP = layer.dataProvider()
print apagar
DP.deleteFeatures(apagar)
progress.setInfo('<b>Classe: %s </b><br/>' %layer.name())
progress.setInfo('- %d feicoes duplicadas removidas.<br/>' %cont)
progress.setInfo('<b>Operacao concluida!</b><br/><br/>')
progress.setInfo('<b>Leandro França - Eng Cart</b><br/>')
time.sleep(8)
iface.messageBar().pushMessage(u'Situacao', "Operacao Concluida com Sucesso!", level=QgsMessageBar.INFO, duration=5)