The code below visualizes data on tree cover percentage, mean hottest month temperature, and average wildfire size in the US. The tree cover percentage and mean hottest month temperature data is worldwide, but the plots are focused on the US.
# load packages
library(ncdf4)
library(CFtime)
library(lattice)
library(RColorBrewer)
library(abind)
library(sf)
library(stars)
library(ggplot2)
library(classInt)
library(units)
The global (Robinson) projections from http://www.naturalearthdata.com (the geography regions one)
#change path as necessary
shape_path <- "C:/Users/Louisa/geog490/data/Rmaps/source/"
regions_shapefile <- paste(shape_path, "ne_50m_geography_regions_polys/ne_50m_geography_regions_polys.shp", sep="")
regions_poly_sf <- st_read(regions_shapefile)
Reading layer `ne_50m_geography_regions_polys' from data source
`C:\Users\Louisa\geog490\data\Rmaps\source\ne_50m_geography_regions_polys\ne_50m_geography_regions_polys.shp'
using driver `ESRI Shapefile'
Simple feature collection with 522 features and 37 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -180 ymin: -89.99993 xmax: 180 ymax: 83.97999
Geodetic CRS: WGS 84
# set path and filename, change as needed
tree_path <- "C:/Users/Louisa/geog490/data/cspace/"
tree_name <- "treecov.nc"
tree_file <- paste(tree_path, tree_name, sep="")
tree <- read_ncdf(tree_file, var = "treecov")
Will return stars object with 259200 cells.
No projection information found in nc file.
Coordinate variable units found to be degrees,
assuming WGS84 Lat/Lon.
# open file
treein <- nc_open(tree_file)
print(treein)
File C:/Users/Louisa/geog490/data/cspace/treecov.nc (NC_FORMAT_CLASSIC):
1 variables (excluding dimension variables):
float treecov[lon,lat]
name: treecov
long_name: treecov
units: 1
_FillValue: -9
2 dimensions:
lon Size:720
standard_name: longitude
long_name: longitude
units: degrees_east
axis: X
lat Size:360
standard_name: latitude
long_name: latitude
units: degrees_north
axis: Y
3 global attributes:
source: UMD Tree Cover Data resampled to 0.5-degrees
data: gl-latlong-8km-landcover.bsq.gz
history: P.J. Bartlein, 20 Feb 2008
treecov_poly <- st_as_sf(tree, as_points = FALSE)
Set limitations to focus on US (or other area of interest)
#reccomend trimming dataset if only looking at one place
plot(treecov_poly, xlim = c(-130, -65), ylim = c(39, 40), key.pos=1, border= NA, main = "Treecover (%)")
The treecover plot displays tree cover canopy percentage per output grid cell.
# set path and filename change as needed
mtemp_path <- "C:/Users/Louisa/geog490/data/cspace/"
mtemp_name <- "cru10min30_new.nc"
mtemp_file <- paste(mtemp_path, mtemp_name, sep="")
#important to select correct variable!
mtemp <- read_ncdf(mtemp_file, var = "mtwa")
Will return stars object with 259200 cells.
No projection information found in nc file.
Coordinate variable units found to be degrees,
assuming WGS84 Lat/Lon.
# open file
tempin <- nc_open(mtemp_file)
print(tempin)
File C:/Users/Louisa/geog490/data/cspace/cru10min30_new.nc (NC_FORMAT_CLASSIC):
4 variables (excluding dimension variables):
float tmp[lon,lat,time]
units: deg_C
missing_value: -99
long_name: 2m air temperature
float mtco[lon,lat]
units: deg_C
missing_value: -99
long_name: mean_temperature_coldest_month
float mtwa[lon,lat]
units: deg_C
missing_value: -99
long_name: mean_temperture_warmest_month
float mat[lon,lat]
units: deg_C
missing_value: -99
long_name: mean_annual_temperature
3 dimensions:
lon Size:720
units: degrees_east
axis: X
lat Size:360
units: degrees_north
axis: Y
time Size:12
units: days since 1900-01-01 00:00:00.0 -0:00
axis: T
6 global attributes:
title: CRU CL 2.0 -- 10min grid sampled every 0.5 degree
institution: http://www.cru.uea.ac.uk/
source: http://www.cru.uea.ac.uk/~markn/cru05/cru05_intro.html
references: New et al. (2002) Climate Res 21:1-25
history: Bartlein 16 Apr 2013
Conventions: CF-1.0
# convert stars object to sf POINTS
tmp_pts <- st_as_sf(mtemp, as_points = TRUE)
Set limitations to focus on area of interest
plot(tmp_pts, xlim = c(-130, -65), ylim = c(39, 40), pch = 15, key.pos= 1, main = "Mean Temp (C)")
The temperature plot displays the mean temperature of the warmest month in celsius.
# set path and filename change as needed
fire_path <- "C:/Users/Louisa/geog490/data/"
fire_name <- "us_fires.nc"
fire_file <- paste(fire_path, fire_name, sep="")
fire <- read_ncdf(fire_file, var = "fpafod_mean_area")
Will return stars object with 6300 cells.
No projection information found in nc file.
Coordinate variable units found to be degrees,
assuming WGS84 Lat/Lon.
# open file
firein <- nc_open(fire_file)
print(firein)
File C:/Users/Louisa/geog490/data/us_fires.nc (NC_FORMAT_NETCDF4):
2 variables (excluding dimension variables):
float fpafod_counts[lon,lat] (Contiguous storage)
units: 1
_FillValue: 1.00000003318135e+32
long_name: Number of fires, 1992-2013
float fpafod_mean_area[lon,lat] (Contiguous storage)
units: ha
_FillValue: 1.00000003318135e+32
long_name: Average Fire Size, 1992-2013
2 dimensions:
lon Size:126
units: degrees_east
long_name: lon
axis: X
lat Size:50
units: degrees_north
long_name: lat
axis: Y
6 global attributes:
title: FPA-FOD Fires
institution: USFS
source: http://www.fs.usda.gov/rds/archive/Product/RDS-2013-0009.3/
references: Short, K.C., 2014, Earth Syst. Sci. Data, 6, 1-27
history: P.J. Bartlein, Thu Jan 28 13:46:10 2021
Conventions: CF-1.6
# convert stars object to sf POINTS
fire_pts <- st_as_sf(fire, as_points = TRUE)
#plot fire
plot(fire_pts, pch = 15, key.pos=1, logz = TRUE, breaks = c(-1,0,.5,1,1.5,2,2.5,3,3.5), at = c(-1,0,.5,1,1.5,2,2.5,3,3.5), main = "Average Wildfire Size (ha)")
The wildfire size plot displays the average wildfire size from 1992-2013. The remaining white spots either do not fit the scale or have no data.
Filter by size, leaving the largest relative fires, and define variable
#filter fire- units are very important
subfire <- dplyr::filter(fire_pts, fpafod_mean_area > units::set_units(100, ha))
#plot subfires with context
plot(st_geometry(regions_poly_sf), xlim = c(-100, -80), ylim = c(30, 50))
plot(subfire, pch = 10, key.pos=1, logz = TRUE, breaks = c(-1,0,.5,1,1.5,2,2.5,3,3.5), at = c(-1,0,.5,1,1.5,2,2.5,3,3.5), col = "red", add=TRUE)
This plot displays only the areas with an average wildfire size above 100 ha.
#plot regions, temp, regions, subfires
plot(st_geometry(regions_poly_sf), xlim = c(-100, -80), ylim = c(30, 50))
plot(tmp_pts, pch = 15, add=TRUE)
plot(st_geometry(regions_poly_sf), xlim = c(-100, -80), ylim = c(30, 50), add=TRUE)
plot(subfire, pch = 9, key.pos=1, logz = TRUE, breaks = c(-1,0,.5,1,1.5,2,2.5,3,3.5), at = c(-1,0,.5,1,1.5,2,2.5,3,3.5), col = "red", add=TRUE)
This displays the large wildfires over the warmest month’s average temperature.
#plot regions, treecover, regions, subfire
plot(st_geometry(regions_poly_sf), xlim = c(-100, -80), ylim = c(30, 50))
plot(treecov_poly,border = NA, add=TRUE)
plot(st_geometry(regions_poly_sf), xlim = c(-100, -80), ylim = c(30, 50), add=TRUE)
plot(subfire, pch = 9, key.pos=1, logz = TRUE, breaks = c(-1,0,.5,1,1.5,2,2.5,3,3.5), at = c(-1,0,.5,1,1.5,2,2.5,3,3.5), col = "red", add=TRUE)
Displays the large wildfires over the tree cover percentage.
On average the large wildfires occur in mostly the west and southwest portions of the US. This pattern is similar to that of the highest temperatures, but not similar to the treecover percentage. This indicates that temperature has a greater influence on wildfires than treecover.