divisions.py
2.93 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
file = open('Maps/UG_Vertice_Concelho.txt')
nlin = -1
vert4MU = {}
conc4MU = {}
MUNames = []
MU4conc = {'Paiva':[], 'Penafiel':[], 'Paredes':[]}
xmin = 100000000000
xmax = -100000000000
ymin = 100000000000
ymax = -100000000000
for line in file:
nlin += 1
if nlin == 0:
continue
lex = line.split()
if nlin < 5 or nlin > 54405:
#print(lex)
continue
if lex[0] not in vert4MU:
vert4MU[lex[0]] = []
conc4MU[lex[0]] = lex[4]
MUNames.append(lex[0])
x = float(lex[2])
y = float(lex[3])
vert4MU[lex[0]].append((x,y))
if xmin > x : xmin = x
if xmax < x : xmax = x
if ymin > y : ymin = y
if ymax < y :
ymax = y
nymax = lex[0]
MU4conc[lex[4]].append(lex[0])
file.close()
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,10))
ax = plt.gca()
ax.set_facecolor('lightgray')
plt.plot([-25000, -25010], [165000, 165010], lw=15, c='royalblue', label='NorthWest')
plt.plot([-25000, -25010], [165000, 165010], lw=15, c='lime', label='NorthEast')
plt.plot([-25000, -25010], [165000, 165010], lw=15, c='fuchsia', label='PaivaWest')
plt.plot([-25000, -25010], [165000, 165010], lw=15, c='yellow', label='PaivaIslands')
plt.plot([-25000, -25010], [165000, 165010], lw=15, c='red', label='PaivaEast')
plt.plot([-25000, -25010], [165000, 165010], lw=17, c='lightgray')
plt.legend()
toPaint = [1]
file = open('subregions/i_fulleast')
for line in file:
xx = []
yy = []
for v in vert4MU[line[:-1]]:
xx.append(v[0])
yy.append(v[1])
plt.fill(xx, yy, facecolor='lime', edgecolor='black', linewidth=1)
file = open('subregions/i_fullwest')
for line in file:
xx = []
yy = []
for v in vert4MU[line[:-1]]:
xx.append(v[0])
yy.append(v[1])
plt.fill(xx, yy, facecolor='royalblue', edgecolor='black', linewidth=1)
file = open('subregions/ip_continent')
for line in file:
xx = []
yy = []
for v in vert4MU[line[:-1]]:
xx.append(v[0])
yy.append(v[1])
plt.fill(xx, yy, facecolor='fuchsia', edgecolor='black', linewidth=1)
file = open('subregions/ip_notmideast')
for line in file:
xx = []
yy = []
for v in vert4MU[line[:-1]]:
xx.append(v[0])
yy.append(v[1])
plt.fill(xx, yy, facecolor='yellow', edgecolor='black', linewidth=1)
file = open('subregions/ip_mideast')
for line in file:
xx = []
yy = []
for v in vert4MU[line[:-1]]:
xx.append(v[0])
yy.append(v[1])
plt.fill(xx, yy, facecolor='red', edgecolor='black', linewidth=1)
#1157
#1169
xx = []
yy = []
#for v in vert4MU["180"]:
# xx.append(v[0])
# yy.append(v[1])
#plt.fill(xx, yy, facecolor='red', edgecolor='black', linewidth=1)
655
675
678
679
682
712
713
#rightside of ipmidtop 1250 898 896
plt.show()