from ipyleaflet import Map, Heatmap
from random import uniform
import time
import pandas as pd
df = pd.read_csv("data/data_harmonized_1.csv")
df.head()
time (UTC) | 1 | 2 | 4 | 6 | 9 | 10 | 12 | 13 | 15 | ... | 46 | 54 | 56 | 57 | 58 | 59 | 61 | 74 | 77 | 82 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2018-07-30 04:00:00+00:00 | 18.140 | 16.141 | 16.427 | 15.760 | 17.475 | 17.855 | 17.284 | 16.332 | 18.331 | ... | 18.426 | 16.808 | 17.284 | 15.664 | 17.284 | 17.379 | 15.091 | 17.855 | 16.141 | 18.331 |
1 | 2018-07-30 04:10:00+00:00 | 18.140 | 16.046 | 16.237 | 15.664 | 17.379 | 17.665 | 17.189 | 16.237 | 18.236 | ... | 18.236 | 16.523 | 17.094 | 15.664 | 17.379 | 17.379 | 15.091 | 17.760 | 16.046 | 18.331 |
2 | 2018-07-30 04:20:00+00:00 | 18.140 | 16.046 | 16.141 | 15.473 | 17.379 | 17.570 | 17.284 | 16.141 | 18.140 | ... | 18.236 | 16.523 | 16.999 | 15.569 | 17.475 | 17.570 | 14.996 | 17.760 | 16.332 | 17.855 |
3 | 2018-07-30 04:30:00+00:00 | 18.045 | 16.046 | 16.237 | 15.378 | 17.284 | 17.570 | 17.379 | 16.046 | 18.140 | ... | 18.236 | 16.903 | 16.808 | 15.569 | 17.284 | 17.570 | 14.996 | 17.665 | 16.332 | 17.475 |
4 | 2018-07-30 04:40:00+00:00 | 17.379 | 16.237 | 16.141 | 15.378 | 17.284 | 17.760 | 17.189 | 16.046 | 17.855 | ... | 18.331 | 17.284 | 16.808 | 15.569 | 17.189 | 17.475 | 14.996 | 17.475 | 16.903 | 17.570 |
5 rows × 78 columns
df2 = pd.read_csv("data/Metadata_Logger.csv")
df2.head()
LOG_NR_2018 | Log_NR_2019 | NAME | NORD_CHTOPO | OST_CHTOPO | ELEV_CHTOPO | |
---|---|---|---|---|---|---|
0 | 1 | 16 | Bubenbergplatz | 46.94729 | 7.43849 | 542.5 |
1 | 2 | 86 | Ostermundigen, Lötschenstr 13 | 46.95289 | 7.48707 | 551.5 |
2 | 3 | - | Thormannstrasse 62 | 46.93888 | 7.45030 | 526.9 |
3 | 4 | 82 | Thunplatz | 46.94065 | 7.45822 | 551.6 |
4 | 5 | - | PH Von Roll Dach (Solar) | 46.95382 | 7.42310 | 553.9 |
Now that we have installed some libraries, we can work with the data:
m = Map(center=[46.948056, 7.4475], zoom=12)
m
Map(center=[46.948056, 7.4475], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'z…
def create_random_data(length):
"Return a list of some random lat/lon/value triples."
return [[uniform(-80, 80),
uniform(-180, 180),
uniform(0, 1000)] for i in range(length)]
def load_climate_data():
return [[row["NORD_CHTOPO"], row["OST_CHTOPO"], 10] for index, row in df2.iterrows()]
heat = Heatmap(locations=load_climate_data(), radius=20, blur=10)
m.add_layer(heat)
# for i in range(100):
# heat.locations = create_random_data(1000)
# time.sleep(0.1)
heat.radius = 30
heat.blur = 50
heat.max = 0.5
heat.gradient = {0.4: 'red', 0.6: 'yellow', 0.7: 'lime', 0.8: 'cyan', 1.0: 'blue'}
#heat.locations = [[uniform(-80, 80), uniform(-180, 180), uniform(0, 1000)] for i in range(1000)]