-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp.A2.clean_polyline.py
61 lines (52 loc) · 2.14 KB
/
p.A2.clean_polyline.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
#
############################################################################
#
# MODULE : p.A2_clean_polyline.py
# AUTHOR(S) : Sanzana P. 01/12/2014
#
# PURPOSE : Identifying OLAF using information of WTI & WTRI
#
# COPYRIGHT : IRSTEA-UC-UCH
# This file is part of GeoPUMMA
#
# 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; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
#############################################################################
#
#
#
import sys
import os
import grass.script as grass
env = grass.gisenv()
print env
directory = os.getcwd()
print directory
import os.path
import shutil
import math
#Declaracion de variables
vectors = grass.read_command("g.list", type='vect')
print vectors
ditch_in=raw_input("Please enter the name of the input ditch : ")
ditch_out=raw_input("Please enter the name of the output ditch : ")
grass.run_command("v.clean",input=ditch_in, type='line', output='ditch_clean_1',tool='snap,rmdangle,prune,rmline,rmsa',thresh='0.01',overwrite=True)
grass.run_command("v.clean",input='ditch_clean_1',type='line',output='ditch_clean_0_01_break',tool='break,snap,rmdangle,prune,rmline,rmsa',thresh='0.01',overwrite=True)
#exportar e importar para limpieza topologica
grass.run_command("v.db.dropcol",map ='ditch_clean_0_01_break', column='cat_')
grass.run_command("v.out.ogr",input='ditch_clean_0_01_break',type='line',dsn='ditch_clean_0_01_break',flags='e',overwrite=True)
folder=directory+"/ditch_clean_0_01_break/ditch_clean_0_01_break.shp"
grass.run_command("v.in.ogr",dsn=folder,output=ditch_out,flags='o',overwrite=True)