-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
38 lines (29 loc) · 998 Bytes
/
generator.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
import json
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import requests
import datetime
ekb = (56.688468, 56.988468, 60.45337, 60.75337)
today = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
data = requests.get('https://www.gorses.na4u.ru/data/COVID.json').json()
coords = []
for i in data['features']:
coords.append(i['geometry']['coordinates'])
coords = pd.DataFrame(coords)
coords=coords[coords[0]>ekb[0]]
coords=coords[coords[0]<ekb[1]]
coords=coords[coords[1]>ekb[2]]
coords=coords[coords[1]<ekb[3]]
norm_coords = (coords-[ekb[0], ekb[2]]).round(2).mul(100)
stats = np.zeros(shape=(32,32))
for i in norm_coords.iterrows():
stats[int(i[1][0]),int(i[1][1])] +=1
fig = plt.figure(frameon=False)
fig.set_size_inches(50,50)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
plt.imshow(stats/stats.max(), aspect='auto', cmap='gist_earth')
plt.savefig(f'{today}.png')
print(f'generated {today}, white is: {stats.max()}')