3  Spatial analysis for remote sensing data

We demonstrate a spatial analysis workflow using the 2024 climate and bushfire data as an example.

We will perform spatial hot spot and cold spot analysis using the rgeoda package and conduct spatial stratified heterogeneity analysis using the gdverse package.

You can install the required packages using the following commands in the R console:

install.packages(c("sf","terra","tidyverse","rgeoda","gdverse","gpboost"),dep = TRUE)

Now we read the data to R and perform some basic data exploration:

Code
library(terra)

burnedarea = rast('./data/1. Data collection/BurnedArea/BurnedArea_2024.tif')
burnedarea
# class       : SpatRaster 
# dimensions  : 359, 288, 1  (nrow, ncol, nlyr)
# resolution  : 0.00449, 0.00449  (x, y)
# extent      : 129, 131, -14.9, -13.3  (xmin, xmax, ymin, ymax)
# coord. ref. : lon/lat WGS 84 
# source      : BurnedArea_2024.tif 
# name        : BurnDate
pre = rast('./data/1. Data collection/Pre/Pre2024.tif')
pre
# class       : SpatRaster 
# dimensions  : 359, 288, 1  (nrow, ncol, nlyr)
# resolution  : 0.00449, 0.00449  (x, y)
# extent      : 129, 131, -14.9, -13.3  (xmin, xmax, ymin, ymax)
# coord. ref. : lon/lat WGS 84 
# source      : Pre2024.tif 
# name        : precipitation
tem = rast('./data/1. Data collection/Tem/Tem2024.tif')
tem
# class       : SpatRaster 
# dimensions  : 37, 30, 1  (nrow, ncol, nlyr)
# resolution  : 0.0449, 0.0449  (x, y)
# extent      : 129, 131, -14.9, -13.3  (xmin, xmax, ymin, ymax)
# coord. ref. : lon/lat WGS 84 
# source      : Tem2024.tif 
# name        : temperature_2m

par(mfrow = c(1, 3))
plot(burnedarea, main = 'Burned area')
plot(pre, main = 'Precipitation')
plot(tem, main = 'Temperature')
par(mfrow = c(1, 1))
Figure 3.1: Maps of the 2024 climate and bushfire data

Since the row and column numbers of the three rasters are not aligned, we first convert the non-NA cells of the temperature raster into a spatial polygon format. Then, we perform zonal statistics on temperature and wildfire data, and finally, remove all NA values corresponding to the three variables.

Code
tem.polygon = terra::as.polygons(tem,aggregate = FALSE)
names(tem.polygon) = "tem"
tem.polygon$pre = terra::zonal(pre,tem.polygon,fun = "mean",na.rm = TRUE)[,1]
tem.polygon$burnedarea = terra::zonal(burnedarea,tem.polygon,fun = "sum",na.rm = TRUE)[,1]
burnedarea.sf = sf::st_as_sf(tem.polygon) |> 
  dplyr::filter(dplyr::if_all(1:3,\(.x) !is.na(.x)))
burnedarea.sf
# Simple feature collection with 644 features and 3 fields
# Geometry type: POLYGON
# Dimension:     XY
# Bounding box:  xmin: 129 ymin: -14.9 xmax: 131 ymax: -13.3
# Geodetic CRS:  WGS 84
# First 10 features:
#    tem  pre burnedarea                       geometry
# 1   28 1893       1250 POLYGON ((130 -13.3, 130 -1...
# 2   28 1856       1529 POLYGON ((130 -13.3, 130 -1...
# 3   28 1888       2203 POLYGON ((130 -13.3, 130 -1...
# 4   28 1884       1289 POLYGON ((131 -13.3, 131 -1...
# 5   28 1865       4247 POLYGON ((131 -13.3, 131 -1...
# 6   28 1873       1991 POLYGON ((131 -13.3, 131 -1...
# 7   28 1882       3056 POLYGON ((130 -13.3, 130 -1...
# 8   28 1871      15835 POLYGON ((130 -13.3, 130 -1...
# 9   28 1860       4848 POLYGON ((130 -13.3, 130 -1...
# 10  28 1875       5896 POLYGON ((130 -13.3, 130 -1...

library(sf)
plot(burnedarea.sf)
Figure 3.2: Maps of the 2024 climate and bushfire data in sf format

save the data to a shapefile:

Code
sf::write_sf(burnedarea.sf,'./data/3. Spatial analysis/burnedarea_2024.shp',overwrite = TRUE)

3.1 Spatial hotspot identification

Aim

This step is designed to identify the spatial hot and cold spots of bushfire burned areas, which will be performed using the rgeoda package.

Description of steps
  1. Load necessary libraries (sf for spatial data, rgeoda for spatial analysis, ggplot2 for data visualization).
  2. Read the burned area and climate data.
  3. Create the spatial weight matrix.
  4. Run spatial hotspot analysis.
  5. Plot the result.
Code
library(sf)
library(rgeoda)
library(ggplot2)

burnedarea = read_sf('./data/3. Spatial analysis/burnedarea_2024.shp')
queen_w = queen_weights(burnedarea)
lisa = local_gstar(queen_w,  burnedarea["burnedarea"])
cats = lisa_clusters(lisa,cutoff = 0.05)
burnedarea$hcp = factor(lisa_labels(lisa)[cats + 1],level = lisa_labels(lisa))

p_color = lisa_colors(lisa)
names(p_color) = lisa_labels(lisa)
p_label = lisa_labels(lisa)[sort(unique(cats + 1))]
ggplot(burnedarea) +
  geom_sf(aes(fill = hcp)) +
  scale_fill_manual(
    values = p_color, 
    labels = p_label) +
  theme_minimal() +
  labs(fill = "Cluster Type")
Figure 3.3: Bushfire burned area spatial hotspot analysis

3.2 Geographical detector for spatial heterogeneity and factor analysis

Aim

This step is designed to identify the climatic driving factors of bushfire burned area. We will use the gdverse package to analyze the power of determinant of climatic drivers on bushfire burned area based on the optimal parameter geographical detector model.

Description of steps
  1. Load necessary libraries (sf for spatial data and gdverse for geographical detector analysis).
  2. Read the burned area and climate data.
  3. Run the OPGD model.
  4. Plot the result.
Code
library(sf)
library(gdverse)

burnedarea = read_sf('./data/3. Spatial analysis/burnedarea_2024.shp')
opgd.m = opgd(burnedarea~tem+pre, data = burnedarea, discnum = 3:15)
opgd.m
# ***   Optimal Parameters-based Geographical Detector     
#                 Factor Detector            
# 
# | variable | Q-statistic | P-value  |
# |:--------:|:-----------:|:--------:|
# |   tem    |   0.1318    | 1.23e-10 |
# |   pre    |   0.0719    | 8.06e-05 |
plot(opgd.m)
Figure 3.4: Climatic driving factors of bushfire burned area