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:
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.
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
Load necessary libraries (sf for spatial data and gdverse for geographical detector analysis).
# Spatial analysis for remote sensing dataWe 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:```rinstall.packages(c("sf","terra","tidyverse","rgeoda","gdverse","gpboost"),dep =TRUE)```Now we read the data to R and perform some basic data exploration:```{r fig-data-exploration, cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}#| fig.cap: "Maps of the 2024 climate and bushfire data"#| code-fold: true#| fig.height: 3.5library(terra)burnedarea = rast('./data/1. Data collection/BurnedArea/BurnedArea_2024.tif')burnedareapre = rast('./data/1. Data collection/Pre/Pre2024.tif')pretem = rast('./data/1. Data collection/Tem/Tem2024.tif')tempar(mfrow = c(1, 3))plot(burnedarea, main = 'Burned area')plot(pre, main = 'Precipitation')plot(tem, main = 'Temperature')par(mfrow = c(1, 1))```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.```{r fig-map-sf-format, cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}#| fig.cap: "Maps of the 2024 climate and bushfire data in sf format"#| code-fold: true#| fig.height: 3.5tem.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.sflibrary(sf)plot(burnedarea.sf)```save the data to a shapefile:```{r, eval = FALSE}#| code-fold: truesf::write_sf(burnedarea.sf,'./data/3. Spatial analysis/burnedarea_2024.shp',overwrite = TRUE)```## Spatial hotspot identification::: {.callout-tip title="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.:::::: {.callout-caution title="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.:::```{r fig-spatial-hotspot, cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}#| fig.cap: "Bushfire burned area spatial hotspot analysis"#| code-fold: true#| fig.height: 4.5library(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")```## Geographical detector for spatial heterogeneity and factor analysis::: {.callout-tip title="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.:::::: {.callout-caution title="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.:::```{r fig-opgd, cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}#| fig.cap: "Climatic driving factors of bushfire burned area"#| code-fold: true#| fig.height: 3.5library(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.mplot(opgd.m)```