-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.py
More file actions
81 lines (77 loc) · 3.31 KB
/
split.py
File metadata and controls
81 lines (77 loc) · 3.31 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#coding=utf-8
import arcpy
import os
shppath = "D:/DaTa/Yangtz/workflow/shape_ehi/fishnet/"
if __name__ == '__main__':
own = []
# for root,dirs,files in os.walk("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\sp_\\1\\"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
# for root,dirs,files in os.walk("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\sp_\\2\\"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
# for root,dirs,files in os.walk("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\sp_\\3\\"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
# for root,dirs,files in os.walk("E:/final/1/"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
for root,dirs,files in os.walk("E:/final/2/"):
for file in files:
if(file.split('.')[-1]=="shp"):
if file.split('.')[0] not in own:
own.append(file.split('.')[0])
for root,dirs,files in os.walk("E:/final/sub/"):
for file in files:
if(file.split('.')[-1]=="shp"):
if file.split('.')[0] not in own:
own.append(file.split('.')[0])
# for root,dirs,files in os.walk("E:/final/3/"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
# for root,dirs,files in os.walk("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\sp_\\split\\"):
# for file in files:
# if(file.split('.')[-1]=="shp"):
# if file.split('.')[0] not in own:
# own.append(file.split('.')[0])
with open("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\record.txt", 'w') as f:
for rec in own:
f.write(rec)
f.write("\n")
own = []
count = 0
with open("D:\\DaTa\\Yangtz\\workflow\\shape_ehi\\record.txt") as f:
for line in f:
own.append(line[0:-1])
count += 1
for num in '2':
print (num)
print (count)
print ("\n")
print ("\n")
print ("\n")
cursor = arcpy.UpdateCursor(shppath + num + ".shp","","","idj")
arcpy.MakeFeatureLayer_management(shppath + num + ".shp", "fine")
# arcpy.env.overwriteOutput = True
for row in cursor:
idj = row.idj
if idj + '\n' not in own:
if not os.path.isfile("E:/final/"+ num + "/" + row.idj + '.shp'):
print ('"idj"=\'' + row.idj + '\'')
arcpy.SelectLayerByAttribute_management("fine", "NEW_SELECTION", '"idj"=\'' + row.idj + '\'')
arcpy.CopyFeatures_management("fine", "E:/final/"+ num + "/" + row.idj + '.shp')
print (row.idj)
try:
cursor.updateRow(row)
except:
print ("update error!",row.idj)