This is a document for visualising the bushfire spread around my family home in Nowra, NSW, Australia.
The data was obtained from NASA - FIRMS Archive Downloads.The frozen copy of this data (accessed on the 3rd of Jan 2020, restricted to Australia, range from 1st Dec to 3rd of Jan 2020) that I obtained can be found here.
Parts of this code will not be reproducible due to the ggmap
Google API. You might want to consult the manual of this package to obtain the instructions of setting up your laptop with the API.
library(tidyverse)
## ── Attaching packages ─────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.2.1 ✓ purrr 0.3.3
## ✓ tibble 2.1.3 ✓ dplyr 0.8.3
## ✓ tidyr 1.0.0 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.4.0
## ── Conflicts ────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(gganimate)
raw = readr::read_csv("DL_FIRE_M6_94441/fire_nrt_M6_94441.csv")
## Parsed with column specification:
## cols(
## latitude = col_double(),
## longitude = col_double(),
## brightness = col_double(),
## scan = col_double(),
## track = col_double(),
## acq_date = col_date(format = ""),
## acq_time = col_character(),
## satellite = col_character(),
## instrument = col_character(),
## confidence = col_double(),
## version = col_character(),
## bright_t31 = col_double(),
## frp = col_double(),
## daynight = col_character()
## )
glimpse(raw)
## Observations: 90,241
## Variables: 14
## $ latitude <dbl> -35.493, -33.992, -33.991, -33.985, -33.983, -33.980, -33.…
## $ longitude <dbl> 149.639, 150.129, 150.118, 150.085, 150.074, 150.051, 150.…
## $ brightness <dbl> 379.8, 380.4, 406.0, 334.4, 335.3, 329.2, 330.7, 327.1, 34…
## $ scan <dbl> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1, 1.0, 1.0, 1.0, 1.0…
## $ track <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ acq_date <date> 2019-12-01, 2019-12-01, 2019-12-01, 2019-12-01, 2019-12-0…
## $ acq_time <chr> "0000", "0000", "0000", "0000", "0000", "0000", "0000", "0…
## $ satellite <chr> "Terra", "Terra", "Terra", "Terra", "Terra", "Terra", "Ter…
## $ instrument <chr> "MODIS", "MODIS", "MODIS", "MODIS", "MODIS", "MODIS", "MOD…
## $ confidence <dbl> 94, 100, 100, 66, 67, 70, 75, 59, 94, 100, 86, 80, 51, 46,…
## $ version <chr> "6.0NRT", "6.0NRT", "6.0NRT", "6.0NRT", "6.0NRT", "6.0NRT"…
## $ bright_t31 <dbl> 288.9, 305.2, 315.7, 299.8, 299.1, 298.9, 299.0, 298.1, 29…
## $ frp <dbl> 156.0, 157.8, 300.1, 28.2, 30.0, 24.0, 26.1, 21.4, 55.2, 1…
## $ daynight <chr> "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D"…
raw$acq_time %>% unique %>% sample(size = 50) ## Four digits time stamp
## [1] "0405" "0050" "0600" "0535" "1400" "0240" "0515" "0130" "1500" "1320"
## [11] "1630" "0125" "0650" "0045" "0025" "0325" "1330" "1525" "0630" "0550"
## [21] "0435" "1435" "0255" "1620" "1455" "1520" "1735" "2330" "1350" "0205"
## [31] "0120" "1650" "1345" "1255" "0520" "0250" "0310" "0040" "1440" "0235"
## [41] "0530" "1530" "0010" "1535" "1715" "2350" "2340" "0635" "1310" "0440"
I am only selecting some variables of interest to me.
clean = raw %>%
dplyr::transmute(
latitude,
longitude,
brightness,
confidence,
bright_t31,
frp,
daynight,
my_time = paste0(acq_date, " ", acq_time) %>%
lubridate::ymd_hm(), ## Aftering pasting the hours and minites, we use lubridate to clean this
confidence,
conf_cat = cut(
confidence,
c(-1, 50, 101),
labels = c("low", "high")) %>% as.factor,
brightness,
bright_cat = cut(
brightness,
c(300, 350, 400, Inf),
labels = c("low", "med", "high")) %>% as.factor
)
glimpse(clean)
## Observations: 90,241
## Variables: 10
## $ latitude <dbl> -35.493, -33.992, -33.991, -33.985, -33.983, -33.980, -33.…
## $ longitude <dbl> 149.639, 150.129, 150.118, 150.085, 150.074, 150.051, 150.…
## $ brightness <dbl> 379.8, 380.4, 406.0, 334.4, 335.3, 329.2, 330.7, 327.1, 34…
## $ confidence <dbl> 94, 100, 100, 66, 67, 70, 75, 59, 94, 100, 86, 80, 51, 46,…
## $ bright_t31 <dbl> 288.9, 305.2, 315.7, 299.8, 299.1, 298.9, 299.0, 298.1, 29…
## $ frp <dbl> 156.0, 157.8, 300.1, 28.2, 30.0, 24.0, 26.1, 21.4, 55.2, 1…
## $ daynight <chr> "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D"…
## $ my_time <dttm> 2019-12-01, 2019-12-01, 2019-12-01, 2019-12-01, 2019-12-0…
## $ conf_cat <fct> high, high, high, high, high, high, high, high, high, high…
## $ bright_cat <fct> med, med, high, low, low, low, low, low, low, med, low, lo…
This code is not reproducible unless you have the correct Google Maps API.
nowra_map <- get_map("Nowra Hill, NSW", zoom = 10)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=Nowra%20Hill,%20NSW&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Nowra+Hill,+NSW&key=xxx
str(nowra_map)
## 'ggmap' chr [1:1280, 1:1280] "#BABAB6" "#D6D6CA" "#EAEADE" "#EAEAE2" ...
## - attr(*, "source")= chr "google"
## - attr(*, "maptype")= chr "terrain"
## - attr(*, "zoom")= num 10
## - attr(*, "bb")=Classes 'tbl_df', 'tbl' and 'data.frame': 1 obs. of 4 variables:
## ..$ ll.lat: num -35.3
## ..$ ll.lon: num 150
## ..$ ur.lat: num -34.6
## ..$ ur.lon: num 151
map_bounds = attr(nowra_map, "bb")
nowra_data = clean %>%
dplyr::filter(
latitude >= map_bounds$ll.lat,
latitude <= map_bounds$ur.lat,
longitude >= map_bounds$ll.lon,
longitude <= map_bounds$ur.lon)
nowra_data %>% glimpse
## Observations: 1,630
## Variables: 10
## $ latitude <dbl> -35.285, -35.284, -35.290, -35.286, -34.964, -34.963, -34.…
## $ longitude <dbl> 150.246, 150.235, 150.171, 150.209, 150.639, 150.627, 150.…
## $ brightness <dbl> 326.3, 335.0, 337.7, 314.1, 323.6, 311.1, 311.6, 319.1, 33…
## $ confidence <dbl> 43, 83, 100, 50, 100, 82, 83, 98, 76, 70, 63, 100, 100, 10…
## $ bright_t31 <dbl> 296.4, 295.3, 290.2, 288.5, 287.4, 285.9, 286.7, 287.0, 30…
## $ frp <dbl> 20.0, 31.8, 44.5, 14.1, 28.1, 15.1, 14.7, 22.3, 95.0, 7.3,…
## $ daynight <chr> "D", "D", "N", "N", "N", "N", "N", "N", "D", "N", "N", "N"…
## $ my_time <dttm> 2019-12-17 00:00:00, 2019-12-17 00:00:00, 2019-12-17 15:1…
## $ conf_cat <fct> low, high, high, low, high, high, high, high, high, high, …
## $ bright_cat <fct> low, low, low, low, low, low, low, low, low, low, low, med…
p1 = ggmap(nowra_map) +
geom_point(data = nowra_data,
aes(x = longitude,
y = latitude,
colour = brightness)) +
geom_point(x = 150.5934431,
y = -34.8432388,
colour = "blue", size = 2) + ## A location near my home
scale_colour_distiller(palette = "Reds", direction = 1) +
transition_states(my_time) +
labs(title = "Time: {closest_state}") +
shadow_trail(distance = 0.05, colour = "black", alpha = 1)
p2 = animate(p1, nframes = 100)
p2