image_output_1.png
from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

import matplotlib.ticker as ticker

import numpy as np

import pandas as pd

import sqlite3

input = sqlite3.connect('../input/FPA_FOD_20170508.sqlite')
df = pd.read_sql_query("SELECT * FROM 'Fires'", input)
epoch = pd.to_datetime(0, unit='s').to_julian_date()
df.DISCOVERY_DATE = pd.to_datetime(df.DISCOVERY_DATE - epoch, unit='D')
df.CONT_DATE = pd.to_datetime(df.CONT_DATE - epoch, unit='D')
df.index = pd.to_datetime(df.DISCOVERY_DATE)
df_wa = df[df.STATE == 'WA']

# analysis for yearly burn area
y=df_wa.FIRE_SIZE.resample('AS').sum().fillna(0)
ax = y.plot(kind='bar',figsize=(10,6))
# set xaxis major labels
# Make most of the ticklabels empty so the labels don't get too crowded
ticklabels = ['']*len(y.index)
# Every 4th ticklable shows the month and day
#ticklabels[::5] = [item.strftime('%b %d') for item in y.index[::4]]
# Every 12th ticklabel includes the year
#ticklabels[::5] = [item.strftime('%b %d\n%Y') for item in y.index[::5]]
ticklabels[::1] = [item.strftime('%Y') for item in y.index[::1]]
ax.xaxis.set_major_formatter(ticker.FixedFormatter(ticklabels))
plt.gcf().autofmt_xdate()
plt.xlabel('Year')
plt.ylabel('Acres Burned');
plt.title('Acres Burned by Year');

lat = df_wa['LATITUDE'].values
lon = df_wa['LONGITUDE'].values
fsize = df_wa['FIRE_SIZE'].values
fig = plt.figure(figsize=(17, 10))
m = Basemap(projection='mill', llcrnrlon=-124.0, llcrnrlat=45.3, urcrnrlon=-117, urcrnrlat=49.1, resolution='h', epsg=4269)
m.drawcoastlines(color='blue')
m.drawcountries(color='blue')
m.drawstates(color='blue')
m.scatter(lon, lat, latlon=True, c=np.log10(fsize), s=fsize * 0.01, cmap='Set1', alpha=0.5)
plt.colorbar(label='$\\log_{10}({\\rm Size Acres})$', fraction=0.02, pad=0.04)
plt.clim(3, 7)