# importing all neccessary packages
import os
import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
# for raster
import rioxarray as rioxr
#for geometry in geopandas
from shapely.geometry import Polygon
from shapely.geometry import Point
from shapely.geometry import box
#now going to read in my data
#url for aqi_2017
#url_17 = 'https://aqs.epa.gov/aqsweb/airdata/daily_aqi_by_county_2017.zip'
= pd.read_csv('data/aqi_17_18/daily_aqi_by_county_2017.csv')
aqi_17
#url for aqi_18
#url_18 = 'https://aqs.epa.gov/aqsweb/airdata/daily_aqi_by_county_2018.zip'
= pd.read_csv('data/aqi_17_18/daily_aqi_by_county_2018.csv')
aqi_18
#reading in the landsat data
= os.path.join(os.getcwd(),'data','landsat_8','landsat8-2018-01-26-sb-simplified.nc')
path = rioxr.open_rasterio(path)
landsat
# checking to make sure that everything looks good
landsat
#reading in the california fire perimeter for this
= gpd.read_file('data/ca_fire_perimeter/California_Fire_Perimeters_2017.shp') ca
Air Quality Index of Santa Barbara County during the 2017 Thomas Fire
Author: Rosemary Juarez
Link to github repo: github repo
Purpose
In December of 2017, The Thomas fire burned throughout Santa Barbara and Ventura county, creating distress and destructing in its wake. This wildfire was one of multiple wildfires occuring in California, making this a hotter topic throughout the years. As a native Ventura county resident, I have seen the effects this wildfire has caused in the community. Not only did I have to miss school, but my parents and I were forced to shelter indoors as the air quality grew worse. With the sky burning blood red for a few days, and smoke hazes filling up the streets of Oxnard, my curiosity grew more. Now that I have a chance to explore what exactly was going due to having data science experience, I can now vizualize the Thomas’s fire impact through air quality. My interest in collecting the air quality during this time can shed light on the correlation between wildfires and air quality. I want to investigate how the Thomas Fire impacted the AQI in Santa Barbara county using public data provided by US Environmental Protection Agency.
Highlights:
- vizualize raster data
- Time series analysis
- geospatial analysis
- remote sensing analysis
- False Color Imagery
Dataset Description
Landsat 8 imagery:
For raster data, this originated from NASA’s Earth Observatory. The landsat imagery has a collection of bands (red, green, blue, near-infrared and shortwave infrared) from the Landsat Collection 2 Level-2 atmosperically corrected surface reflectance data, collected by the Landsat 8 satellite. the landsat imagery used in this report is post-2017
Thomas Fire Perimeter:
For our Vector data, the Thomas fire perimeter polygon came from the CA State Geoportal, which comes with multiple fire perimeters.
Air Quality Index
The Air Quality Index (AQI) data from the US Environmental Protection Agency. This data provides AQI coverage period from 2017 - 2018.
References to datasets
Landsat 8 imagery: https://planetarycomputer.microsoft.com/dataset/landsat-c2-l2
Thomas Fire Perimeter: https://gis.data.ca.gov/datasets/CALFIRE-Forestry::california-fire-perimeters-all-1/about
AQI: https://aqs.epa.gov/aqsweb/airdata/download_files.html#AQI
Importing Data
We will first focus on importing all necessary data required for running this report. We must first import all important packages required to read and run the datasets. There will be a combination of vector and raster data.
Geographical context of data
Since We are primarily exploring Santa Barbara county, our focus should be in this region. In the case of our landsat imagery, we are given a wide 30m x 30m pixel dimension of our area, giving us a relatively good spatial resolution for the area we are interested. As for the fire perimeter, we will need to filter our data to only include the Thomas fire. This will show us only the fire perimeter of Thomas fire, which includes SB and Ventura county. Our AQI data is not spatial, therefore we do not need to explain further geographical context except that we will filter to only include santa barbara county.
For data wrangling, we will be using numpy’s methods of squeeze()
and drop()
to remove band coordinates from our landsat data. We use rioxarray to manipulate our raster data. Lastly, matplotlib.pyplot is used to plot our raster map
#first need to wrangle data
# and here i am just squeezing and dropping unneccesary data information, such as the band coordinates
= landsat.squeeze()
landsat = landsat.drop('band')
landsat
#filtering for thomas fire only
= ca[ca.FIRE_NAME == 'THOMAS']
thomas
#changing the crs to landsat so that it aligns well
= thomas.to_crs(landsat.rio.crs)
thomas
# Customizing my map now to highlight thomas fire and the vegetation
= plt.subplots()
fig, ax
'swir22', 'nir08', 'red']].to_array().plot.imshow(robust = True)
landsat[[= ax,
thomas.plot(ax = 'white',
edgecolor = 'none')
facecolor 'Post-Thomas fire vegetation Damage (2017)', fontsize=13)
ax.set_title('off')
ax.axis( plt.show()
figure 1: The map above shows the region in which the Thomas fire burned. The city of Ojai was surrounded by the Thomas fire, as seen to be the gap in between the red features. The red mark on the map shows vegetation damaged caused by the thomas fire.
Data Exploration
Now that we established our geographic area of interest, we now shift towards looking at the Air Quality Index or AQI of Santa Barbara County. For this, we require more data exploration on our end, as this requires filtering and merging datasets in order to accomplish a time series as our final output.
Our time series will cover the air quality index from 2017 to 2018 to give us insight and analyze patterns noted before, during, and after the Thomas fire. This will involve more data wrangling to vizualize what we want. This includes using pandas package for pd.groupby()
, and pd.to_datetime
for some of our changes. Other data cleanup includes filtering for santa barbara county and renaming columns
#finding the mean aqi by county
'county Name').mean('AQI')
aqi_17.groupby(
# concatanating two dataframes together
= pd.concat([aqi_17, aqi_18])
aqi
# re-assign the column names - .str.lower() makes them lower case
= aqi.columns.str.lower()
aqi.columns
# re-assign the column names again
= aqi.columns.str.replace(' ','_')
aqi.columns
# selecting data from SB county using conditionals
= aqi[aqi.county_name == 'Santa Barbara']
aqi_sb
#removing columns using.drop()
= aqi_sb.drop(columns = ['state_name', 'county_name', 'state_code', 'county_code'])
aqi_sb
#changing to datetime for date
'date'] = pd.to_datetime(aqi_sb.date)
aqi_sb[
#reseting aqi index
= True, drop = True)
aqi_sb.reset_index(inplace
# adding the new column by updating it
'five_day_average'] = aqi_sb.aqi.rolling(window = 5).mean()
aqi_sb[
#plot
#creating colors first for the lines
= {'aqi': '#d3d3d3',
colors 'five_day_average': 'red'}
#line plot of the AQI using the new column i just added
= 'line',
aqi_sb.plot(kind = 'date',
x = ['aqi', 'five_day_average'],
y = colors,
color ='daily and 5-day average AQI in SB County',
title = 'AQI Value')
ylabel plt.show()
figure 2: time series coverage from 2017-2018 on AQI in Santa Barbara. There is a spike in Air Quality during Thomas Fire
analysis
We find that during the end of December of 2017, the AQI peaked approximately past the value of 250. According to the EPA, a value higher than 200 is considered ‘very unhealthy’, and could pose health risks to those exposed. Given that we see that there were high AQI values during the Thomas Fire, we can assume that there is correlation between the two. WE clearly see an impact from the fires affecting the AQI.
Our false color imagery depicting the Thomas Fire scars reveals the extent of recent damage done to the vegetation during post-wilfire. Since the vegetation scars coincide with the fire perimeter of Thomas fires, we can also conclude that the fire caused those scars. Overall, the impact Thomas Fire caused to AQI is clear, and we can visually represent it.
Final Output
= plt.subplots(2,1, figsize=(12,9))
fig, (ax1, ax2)
# AQI plot
= ax1,
aqi_sb.plot(ax = 'line',
kind = 'date',
x = ['aqi', 'five_day_average'],
y = colors,
color ='daily and 5-day average AQI in SB County',
title = 'AQI Value')
ylabel #------------------------------------------------------------------------
# False Color Imagery
'swir22', 'nir08', 'red']].to_array().plot.imshow(robust = True)
landsat[[= ax2,
thomas.plot(ax = 'white',
edgecolor = 'none',
facecolor
)=.3)
fig.subplots_adjust(hspace'Post-Thomas fire vegetation Damage (2017)', fontsize=13)
ax2.set_title('off')
ax2.axis( plt.show()
figure 3: final output depicting the AQI in Santa Barbara County and the spatial vizualization of the Thomas Fire’s damage and extent
Citations
US Environmental Protection Agency. Air Quality System Data Mart. available via https://www.epa.gov/outdoor-air-quality-data. Accessed November 28, 2023.
CALFIRE, USDA Forest Service, other Federal Partners. California Fire Perimeters(All). Available via https://gis.data.ca.gov/maps/CALFIRE-Forestry::california-fire-perimeters-all/about. Accessed November 28, 2023.
NASA, USGS, Microsoft. Landsat Collection 2 Level-2 Science products. Available via https://planetarycomputer.microsoft.com/dataset/landsat-c2-l2. Accessed November 28, 2023.