-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript-climate-nlfiremap.py
More file actions
46 lines (32 loc) · 1.22 KB
/
script-climate-nlfiremap.py
File metadata and controls
46 lines (32 loc) · 1.22 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
import requests
import geopandas
import pandas as pd
import json
import datawrappergraphics
# Live chart ID: Os1m6
CHART_ID = "FAPp3"
# Make HTTP request for the data and put into a geopandas dataframe.
data = geopandas.read_file("/vsicurl/https://cwfis.cfs.nrcan.gc.ca/downloads/hotspots/perimeters.shp")
data = data.to_crs("EPSG:4326")
data["stroke"] = "#C42127"
data["stroke-width"] = 2
data["fill-opacity"] = 0.3
data["fill"] = "#C42127"
data["title"] = data["UID"]
# markers1 = [datawrappergraphics.Map(chart_id=CHART_ID).get_markers()[0]]
# markers2 = datawrappergraphics.Map(chart_id=CHART_ID).get_markers()[-2:]
# markers = [x for n in (markers1, markers2) for x in n]
# with open('./assets/shapes/shapes-nlfiremap.json', 'w', encoding='utf-8') as f:
# json.dump(markers, f)
# data = data[data["UID"].isin([8709641, 8709640])]
highway = geopandas.read_file("./assets/shapes/highway.geojson")
highway["fill"] = False
highway["stroke"] = "#000000"
highway["stroke-width"] = 2
data = data.append(highway)
print(data)
map = (datawrappergraphics.Map(chart_id=CHART_ID)
.data(data, append="./assets/shapes/shapes-nlfiremap.json")
.footer(source="Natural Resources Canada")
.publish()
)