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 GD package.

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

install.packages(c("sf","terra","tidyverse","rgeoda","GD","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 
# size        : 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 (EPSG:4326) 
# source      : BurnedArea_2024.tif 
# name        : BurnDate
pre = rast('./data/1. Data collection/Pre/Pre2024.tif')
pre
# class       : SpatRaster 
# size        : 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 (EPSG:4326) 
# source      : Pre2024.tif 
# name        : precipitation
tem = rast('./data/1. Data collection/Tem/Tem2024.tif')
tem
# class       : SpatRaster 
# size        : 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 (EPSG:4326) 
# source      : Tem2024.tif 
# name        : temperature_2m

options(terra.pal = grDevices::terrain.colors(100,rev = T))
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 GD 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.
Code
library(sf)
library(GD)

burnedarea = read_sf('./data/3. Spatial analysis/burnedarea_2024.shp')
opgd.m = gdm(burnedarea~tem+pre, 
             continuous_variable = c("tem", "pre"),
             data = sf::st_drop_geometry(burnedarea),
             discmethod = c("equal","natural","quantile"), 
             discitv = 3:15)
opgd.m
# Explanatory variables include 2 continuous variables.
# 
# optimal discretization result of tem
# method             :  quantile
# number of intervals:  13
# intervals:
#  26.7 26.8 27 27.2 27.3 27.5 27.7 27.7 27.7 27.8 27.9 28 28 28.2
# numbers of data within intervals:
#  52 47 52 47 53 47 50 49 50 50 48 50 49
# 
# optimal discretization result of pre
# method             :  natural
# number of intervals:  14
# intervals:
#  1589 1650 1712 1736 1758 1787 1816 1844 1870 1896 1924 1949 1977 2011 2067
# numbers of data within intervals:
#  3 16 71 40 40 44 50 76 68 62 57 52 43 22
# 
# Geographical detectors results:
# 
# Factor detector:
#   variable     qv      sig
# 1      tem 0.1301 1.79e-10
# 2      pre 0.0733 2.86e-05
# 
# Risk detector:
# tem
#              itv meanrisk
# 1   [26.69,26.8]     3730
# 2   (26.8,27.02]     4871
# 3   (27.02,27.2]     5984
# 4   (27.2,27.33]     5647
# 5  (27.33,27.51]     5514
# 6  (27.51,27.66]     9252
# 7  (27.66,27.69]     8948
# 8  (27.69,27.74]     6647
# 9  (27.74,27.83]     9489
# 10 (27.83,27.91]     7340
# 11 (27.91,27.96]     5083
# 12 (27.96,28.02]     7738
# 13 (28.02,28.16]     7136
# 
# pre
#                    itv meanrisk
# 1  [1.59e+03,1.65e+03]     3435
# 2  (1.65e+03,1.71e+03]     5166
# 3  (1.71e+03,1.74e+03]     4348
# 4  (1.74e+03,1.76e+03]     4829
# 5  (1.76e+03,1.79e+03]     7293
# 6  (1.79e+03,1.82e+03]     5739
# 7  (1.82e+03,1.84e+03]     6155
# 8  (1.84e+03,1.87e+03]     7578
# 9   (1.87e+03,1.9e+03]     7887
# 10  (1.9e+03,1.92e+03]     7212
# 11 (1.92e+03,1.95e+03]     7933
# 12 (1.95e+03,1.98e+03]     8390
# 13 (1.98e+03,2.01e+03]     6340
# 14 (2.01e+03,2.07e+03]     7009
# 
# tem
#         interval [26.69,26.8] (26.8,27.02] (27.02,27.2]
# 1   [26.69,26.8]         <NA>         <NA>         <NA>
# 2   (26.8,27.02]            N         <NA>         <NA>
# 3   (27.02,27.2]            Y            N         <NA>
# 4   (27.2,27.33]            Y            N            N
# 5  (27.33,27.51]            Y            N            N
# 6  (27.51,27.66]            Y            Y            Y
# 7  (27.66,27.69]            Y            Y            Y
# 8  (27.69,27.74]            Y            Y            N
# 9  (27.74,27.83]            Y            Y            Y
# 10 (27.83,27.91]            Y            Y            N
# 11 (27.91,27.96]            N            N            N
# 12 (27.96,28.02]            Y            Y            N
# 13 (28.02,28.16]            Y            Y            N
#    (27.2,27.33] (27.33,27.51] (27.51,27.66] (27.66,27.69]
# 1          <NA>          <NA>          <NA>          <NA>
# 2          <NA>          <NA>          <NA>          <NA>
# 3          <NA>          <NA>          <NA>          <NA>
# 4          <NA>          <NA>          <NA>          <NA>
# 5             N          <NA>          <NA>          <NA>
# 6             Y             Y          <NA>          <NA>
# 7             Y             Y             N          <NA>
# 8             N             N             Y             Y
# 9             Y             Y             N             N
# 10            N             Y             Y             N
# 11            N             N             Y             Y
# 12            Y             Y             N             N
# 13            N             N             Y             N
#    (27.69,27.74] (27.74,27.83] (27.83,27.91] (27.91,27.96]
# 1           <NA>          <NA>          <NA>          <NA>
# 2           <NA>          <NA>          <NA>          <NA>
# 3           <NA>          <NA>          <NA>          <NA>
# 4           <NA>          <NA>          <NA>          <NA>
# 5           <NA>          <NA>          <NA>          <NA>
# 6           <NA>          <NA>          <NA>          <NA>
# 7           <NA>          <NA>          <NA>          <NA>
# 8           <NA>          <NA>          <NA>          <NA>
# 9              Y          <NA>          <NA>          <NA>
# 10             N             Y          <NA>          <NA>
# 11             N             Y             Y          <NA>
# 12             N             N             N             Y
# 13             N             Y             N             N
#    (27.96,28.02] (28.02,28.16]
# 1           <NA>          <NA>
# 2           <NA>          <NA>
# 3           <NA>          <NA>
# 4           <NA>          <NA>
# 5           <NA>          <NA>
# 6           <NA>          <NA>
# 7           <NA>          <NA>
# 8           <NA>          <NA>
# 9           <NA>          <NA>
# 10          <NA>          <NA>
# 11          <NA>          <NA>
# 12          <NA>          <NA>
# 13             N          <NA>
# 
# pre
#               interval [1.59e+03,1.65e+03] (1.65e+03,1.71e+03]
# 1  [1.59e+03,1.65e+03]                <NA>                <NA>
# 2  (1.65e+03,1.71e+03]                   N                <NA>
# 3  (1.71e+03,1.74e+03]                   N                   N
# 4  (1.74e+03,1.76e+03]                   N                   N
# 5  (1.76e+03,1.79e+03]                   Y                   Y
# 6  (1.79e+03,1.82e+03]                   N                   N
# 7  (1.82e+03,1.84e+03]                   N                   N
# 8  (1.84e+03,1.87e+03]                   Y                   Y
# 9   (1.87e+03,1.9e+03]                   Y                   Y
# 10  (1.9e+03,1.92e+03]                   Y                   N
# 11 (1.92e+03,1.95e+03]                   Y                   Y
# 12 (1.95e+03,1.98e+03]                   Y                   Y
# 13 (1.98e+03,2.01e+03]                   N                   N
# 14 (2.01e+03,2.07e+03]                   N                   N
#    (1.71e+03,1.74e+03] (1.74e+03,1.76e+03] (1.76e+03,1.79e+03]
# 1                 <NA>                <NA>                <NA>
# 2                 <NA>                <NA>                <NA>
# 3                 <NA>                <NA>                <NA>
# 4                    N                <NA>                <NA>
# 5                    Y                   Y                <NA>
# 6                    N                   N                   N
# 7                    Y                   N                   N
# 8                    Y                   Y                   N
# 9                    Y                   Y                   N
# 10                   Y                   Y                   N
# 11                   Y                   Y                   N
# 12                   Y                   Y                   N
# 13                   Y                   N                   N
# 14                   Y                   N                   N
#    (1.79e+03,1.82e+03] (1.82e+03,1.84e+03] (1.84e+03,1.87e+03]
# 1                 <NA>                <NA>                <NA>
# 2                 <NA>                <NA>                <NA>
# 3                 <NA>                <NA>                <NA>
# 4                 <NA>                <NA>                <NA>
# 5                 <NA>                <NA>                <NA>
# 6                 <NA>                <NA>                <NA>
# 7                    N                <NA>                <NA>
# 8                    N                   N                <NA>
# 9                    Y                   N                   N
# 10                   N                   N                   N
# 11                   Y                   Y                   N
# 12                   Y                   Y                   N
# 13                   N                   N                   N
# 14                   N                   N                   N
#    (1.87e+03,1.9e+03] (1.9e+03,1.92e+03] (1.92e+03,1.95e+03]
# 1                <NA>               <NA>                <NA>
# 2                <NA>               <NA>                <NA>
# 3                <NA>               <NA>                <NA>
# 4                <NA>               <NA>                <NA>
# 5                <NA>               <NA>                <NA>
# 6                <NA>               <NA>                <NA>
# 7                <NA>               <NA>                <NA>
# 8                <NA>               <NA>                <NA>
# 9                <NA>               <NA>                <NA>
# 10                  N               <NA>                <NA>
# 11                  N                  N                <NA>
# 12                  N                  N                   N
# 13                  N                  N                   N
# 14                  N                  N                   N
#    (1.95e+03,1.98e+03] (1.98e+03,2.01e+03] (2.01e+03,2.07e+03]
# 1                 <NA>                <NA>                <NA>
# 2                 <NA>                <NA>                <NA>
# 3                 <NA>                <NA>                <NA>
# 4                 <NA>                <NA>                <NA>
# 5                 <NA>                <NA>                <NA>
# 6                 <NA>                <NA>                <NA>
# 7                 <NA>                <NA>                <NA>
# 8                 <NA>                <NA>                <NA>
# 9                 <NA>                <NA>                <NA>
# 10                <NA>                <NA>                <NA>
# 11                <NA>                <NA>                <NA>
# 12                <NA>                <NA>                <NA>
# 13                   Y                <NA>                <NA>
# 14                   N                   N                <NA>
# 
# Interaction detector:
#   variable   tem pre
# 1      tem    NA  NA
# 2      pre 0.321  NA
# 
# Ecological detector:
#   variable  tem  pre
# 1      tem <NA> <NA>
# 2      pre    Y <NA>