-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfire_analysis.py
70 lines (59 loc) · 1.77 KB
/
fire_analysis.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
60
61
62
63
64
65
66
67
68
69
70
import csv
from datetime import datetime
from plotly.graph_objs import Scattergeo, Layout
from plotly import offline
# Explore the structure of the data.
filename = 'data/world_fires_7_day.csv'
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
# Get dates and high and low temperatures from this file.
lats, lons, brights = [], [], []
for row in reader:
print(row)
try:
current_date = datetime.strptime(row[5], '%Y-%m-%d')
except IndexError:
print("No date provided")
else:
try:
lat = float(row[0])
long = float(row[1])
bright = float(row[2])
print(lat, long, bright)
except ValueError:
print(f"Missing data for {current_date}")
else:
lats.append(lat)
lons.append(long)
brights.append(bright)
'''
print(all_fire_data)
all_eq_dicts = all_eq_data['features']
mags, lons, lats, hover_texts = [], [], [], []
for eq_dict in all_eq_dicts:
mag = eq_dict['properties']['mag']
lon = eq_dict['geometry']['coordinates'][0]
lat = eq_dict['geometry']['coordinates'][1]
title = eq_dict['properties']['title']
mags.append(mag)
lons.append(lon)
lats.append(lat)
hover_texts.append(title)
'''
# Map the earthquakes.
data = [{
'type': 'scattergeo',
'lon':lons,
'lat':lats,
'marker': {
'size': [bright/50 for bright in brights],
'color': brights,
'colorscale': 'Viridis',
'reversescale': True,
'colorbar': {'title': 'Brightness'},
},
}]
my_layout = Layout(title='Global Fires')
fig = {'data': data, 'layout': my_layout}
offline.plot(fig, filename='global_fires.html')