-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsec4.qmd
148 lines (124 loc) · 5.07 KB
/
sec4.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Geospatial artificial intelligence (GeoAI) for remote sensing data
## GeoAI for spatial prediction of future bushfire
### Future climate data collection
::: {.callout-tip title="Aim"}
We separately collected CMIP6 datasets of temperature and precipitation for 2024 and 2030. The 2024 data will be used for model training, followed by predicting bushfire burn areas for 2030.
:::
::: {.callout-caution title="Description of steps"}
1. Load NEX-GDDP-CMIP6 data from Google Earth Engine.
2. Aggregate and export the temperature and precipitation data for 2024.
3. Aggregate and export the temperature and precipitation data for 2030.
:::
```js
// Load the CMIP6 dataset
var dataset = ee.ImageCollection("NASA/GDDP-CMIP6")
.filter(ee.Filter.eq('model', 'ACCESS-CM2')) // Select climate model
.filter(ee.Filter.eq('scenario', 'ssp585')) // Select SSP scenario
.filterBounds(roi); // Restrict to the region of interest (ROI)
// Extract variables
var temperature = dataset.select('tas'); // Daily mean temperature (unit: K)
var precipitation = dataset.select('pr'); // Daily precipitation (unit: kg m-2 s-1)
// Aggregate data for 2024 and 2030
var tem24 = temperature.filter(ee.Filter.calendarRange(2024, 2024, 'year')).mean().clip(roi).subtract(273.15); // Annual mean temperature for 2024 (°C)
var tem30 = temperature.filter(ee.Filter.calendarRange(2030, 2030, 'year')).mean().clip(roi).subtract(273.15); // Annual mean temperature for 2030 (°C)
var pre24 = precipitation.filter(ee.Filter.calendarRange(2024, 2024, 'year')).sum().clip(roi).multiply(86400).multiply(365); // Annual total precipitation for 2024 (mm)
var pre30 = precipitation.filter(ee.Filter.calendarRange(2030, 2030, 'year')).sum().clip(roi).multiply(86400).multiply(365); // Annual total precipitation for 2030 (mm)
// Export aggregated data to Google Drive
Export.image.toDrive({
image: tem24,
description: 'tem24',
scale: 27830,
region: roi,
fileFormat: 'GeoTIFF'
});
Export.image.toDrive({
image: tem30,
description: 'tem30',
scale: 27830,
region: roi,
fileFormat: 'GeoTIFF'
});
Export.image.toDrive({
image: pre24,
description: 'pre24',
scale: 27830,
region: roi,
fileFormat: 'GeoTIFF'
});
Export.image.toDrive({
image: pre30,
description: 'pre30',
scale: 27830,
region: roi,
fileFormat: 'GeoTIFF'
});
```
### GeoAI modelling
::: {.callout-tip title="Aim"}
The step uses the gpboost model to fit temperature and precipitation data in 2024 for the next step of spatial prediction.
:::
::: {.callout-caution title="Description of steps"}
1. Load necessary libraries and data.
2. Read the data containing burned area and climate data.
3. Process the data to fit the gpboost model.
4. Build an gpboost model.
:::
See [here](https://towardsdatascience.com/tree-boosting-for-spatial-data-789145d6d97d/?sk=4f9924d378dbb517e883fc9c612c34f1) for more details about the gpboost model on spatio-temporal data.
```{r , cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}
#| code-fold: true
library(terra)
pre24 = terra::rast('./data/4. GeoAI Modeling/pre24.tif')
tem24 = terra::rast('./data/4. GeoAI Modeling/tem24.tif')
burnedarea = terra::rast('./data/1. Data collection/BurnedArea/BurnedArea_2024.tif') |>
terra::resample(tem24,method = 'average')
d24 = c(pre24,tem24,burnedarea)
names(d24) = c("pre","tem","burned")
d24 = d24 |>
terra::as.polygons(aggregate = FALSE) |>
sf::st_as_sf() |>
dplyr::filter(dplyr::if_all(1:3,\(.x) !is.na(.x)))
d24
library(gpboost)
gp_model = GPModel(gp_coords = sdsfun::sf_coordinates(d24),
cov_function = "exponential")
# Training
bst = gpboost(data = as.matrix(sf::st_drop_geometry(d24)[,1:2]),
label = as.matrix(sf::st_drop_geometry(d24)[,3,drop = FALSE]),
gp_model = gp_model, objective = "regression_l2", verbose = 0)
bst
```
### Spatial prediction
::: {.callout-tip title="Aim"}
In this step, the gpboost model constructed in the previous step is used to predict the burned area of 2030.
:::
::: {.callout-caution title="Description of steps"}
1. Read the 2030 futural climate data.
2. Process the data to use the gpboost model to predict.
3. Do spatial prediction by the gpboost model.
:::
```{r , cache = FALSE, message = FALSE, echo=!knitr::is_latex_output()}
#| code-fold: true
pre30 = terra::rast('./data/4. GeoAI Modeling/pre30.tif')
tem30 = terra::rast('./data/4. GeoAI Modeling/tem30.tif')
d30 = c(pre30,tem30)
names(d30) = c("pre","tem")
d30 = d30 |>
terra::as.polygons(aggregate = FALSE) |>
sf::st_as_sf() |>
dplyr::filter(dplyr::if_all(1:3,\(.x) !is.na(.x)))
d30
pred = predict(bst, data = as.matrix(sf::st_drop_geometry(d30)[,1:2]),
gp_coords_pred = sdsfun::sf_coordinates(d30),
predict_var = TRUE, pred_latent = FALSE)
pred
d30$burned = pred$response_mean
d30
```
## Analysing future bushfire patterns
::: {.callout-tip title="Aim"}
In this step, the predicted burned area of 2030 is used to analyse the future bushfire patterns.
:::
::: {.callout-caution title="Description of steps"}
1. Visualise the predicted burned area of 2030.
2. Analyse the future bushfire patterns.
:::