Fire research at the National Institute of Standards and Technology (NIST) dates back to the early 1900's following the need for a standardized fire hydrant coupling after the Great Baltimore Fire. Fast-forward to the 1980s and for the last 30 years, NIST researchers have been performaning experiments and running computer simulations following fire incidents to advance the field of fire safety.
NIST researchers wrote detailed reports of their work following these fires, but an intuitive, centralized source of this material did not exist. Therefore, we wanted to build an interface to fix this. We felt a map that showed where the fires occured with interactivity to link to the reports would be an interesting project.
In [11]:
import pandas as pd
from bokeh.models.glyphs import Circle
from bokeh.plotting import show, output_notebook,figure
from bokeh.models import (
GMapPlot, GMapOptions, Range1d, ColumnDataSource, LinearAxis,
PanTool, WheelZoomTool,HoverTool, TapTool, OpenURL)
output_notebook()
In [12]:
data = pd.read_csv('study_data.csv')
In [13]:
data.head()
Out[13]:
The addresses of the fires were geocoded to generate the lattitude and longitude for each fire. The studies were then coded into one of four categories: LODD/LODI (a fire with a firefighter Line of Duty Death or Line of Duty Injury), Civilian Loss, WUI (wildland urban interface fire) or LODD/LODI and Civilian Loss. The data file also includes the NIST hosting link of the report so that we can link to it through first class bokeh features.
The latitude, longitude, and zoom are set to view all of the United States and Puerto Rico.
In [14]:
x_range = Range1d()
y_range = Range1d()
map_options = GMapOptions(lat=39., lng=-98, zoom=3)
plot = GMapPlot(
x_range=x_range, y_range=y_range,
map_options=map_options,
title = "NIST Fire Studies", plot_width=875, plot_height=500
)
plot.map_options.map_type="terrain"
In [15]:
source = ColumnDataSource({'lat':data['Latitude'],'lon':data['Longitude'],'studys': data['Study'],
'report': data['Report'],'fill':data['Color'],'type':data['Type'],'date':data['Date']})
circle = Circle(x="lon",y="lat",size=15,fill_color="fill")
plot.add_glyph(source, circle)
pan = PanTool()
wheel_zoom = WheelZoomTool()
hover = HoverTool()
hover.tooltips = [('Study Title','@studys'),('Date','@date'),('Type','@type')]
tap = TapTool()
url = "@report"
TapTool.callback = OpenURL(url=url)
plot.add_tools(pan,wheel_zoom,hover,tap)
In [16]:
show(plot)
Out[16]:
This is clearly a simple example, but that is point. With minimal code, the final product is an interative map that highlights where prior fires have been studied by NIST researchers.
In [ ]:
In [ ]: