干货分享 | 地理探测器R语言包使用方法(中文版)
使用“GD”包,请引用:
Song, Y., Wang, J., Ge, Y. & Xu, C. (2020) “An optimal parameters-based geographical detector model enhances geographic characteristics of explanatory variables for spatial heterogeneity analysis: Cases with different types of spatial data”, GIScience & Remote Sensing. 57(5), 593-610
1
关于“GD”包
地理探测器可解决以下问题:
从空间异质性角度探索潜在因素或解释变量。
探索地理变量的潜在交互影响。
从潜在的解释变量中识别高风险或低风险区域。
GD包可快速实现以下分析:
它包含有多种监督和非监督空间数据离散化方法,以及连续变量的最优空间离散化一步到位的解决方案;
它包含地理探测器的四个主要功能,包括因子探测器,风险探测器,交互探测器和生态探测器;
可用于比较空间单元的尺度影响;
提供空间分析结果的多种可视化函数;
包含地理探测器每个空间分析步骤中详细的显著性分析结果。
一步到位的地理探测器分析函数 gdm (推荐)
“GD”提供了一个一步到位的空间数据离散化和地理探测器分析的函数gdm。该函数的输出为所有计算步骤的结果数据和全部可视化结果。
例如:
## install and library the pacakge
install.packages("GD")
library("GD")
## Example 1
## NDVI: ndvi_40
## set optional parameters of optimal discretization
## optional methods: equal, natural, quantile, geometric, sd and manual
discmethod <- c("equal","natural","quantile")
discitv <- c(4:6)
## "gdm" function
## In this case, Climatezone and Mining are categorical variables,
## and Tempchange and GDP are continuous variables.
ndvigdm <- gdm(NDVIchange ~ Climatezone + Mining + Tempchange + GDP,continuous_variable = c("Tempchange", "GDP"),
data = ndvi_40,
discmethod = discmethod, discitv = discitv) # ~3s
ndvigdm
plot(ndvigdm)
## Example 2
## H1N1: h1n1_100
## set optional parameters of optimal discretization
discmethod<-c("equal","natural","quantile","geometric","sd")
discitv <- c(3:7)
continuous_variable<-colnames(h1n1_100)[-c(1,11)]
## "gdm" function
h1n1gdm <- gdm(H1N1 ~ .,
continuous_variable = continuous_variable,
data = h1n1_100,
discmethod = discmethod, discitv = discitv)
h1n1gdm
plot(h1n1gdm)
2
地理探测器模型集
地理探测器可以解决空间分层异质性问题 (Wang et al. 2010, Wang et al. 2016)。
图 1. 地理探测器应用趋势综述 (总引用数截至2020年6月). (Song et al. 2020)
图 2. 空间分析过程和“GD”包中函数的关系 (Song et al. 2020)
更多关于“GD”包的内容,请参考GD: Optimal Parameters-based Geographical Detectors for Assessing Spatial Factors。
更多关于地理探测器的应用,请参考Geodetector website.
3
空间数据离散化
在地理探测器中,连续变量需要通过空间数据离散化的方式转化为类别变量。“GD”提供了两种解决方案。第一,使用已知的离散化方法和数量,用disc函数离散化。第二种方法是用optidisc对一系列备选的离散化方法和数量,通过对比的方式,选择最优的离散化方法和数量的组合。
下面以“GD”中提供的ndvi_40数据为例说明这两种方法如何使用。
install.packages("GD")
library("GD")
data("ndvi_40")
head(ndvi_40)[1:3,]
根据已知参数离散化: disc
## discretization methods: equal, natural, quantile (default), geometric, sd and manual ds1 <- disc(ndvi_40$Tempchange, 4)
ds1
plot(ds1)
最优空间离散化: optidisc
## set optional discretization methods and numbers of intervals discmethod <- c("equal","natural","quantile","geometric","sd")
discitv <- c(4:7)
## optimal discretization
odc1<-optidisc(NDVIchange~ Tempchange, data = ndvi_40,discmethod, discitv)
odc1
plot(odc1)
图 3. 最优空间数据离散化过程和方法
4
地理探测器
因子探测器: gd
## a categorical explanatory variable
g1 <- gd(NDVIchange ~ Climatezone, data = ndvi_40)
g1
## multiple categorical explanatory variables
g2 <- gd(NDVIchange ~ ., data = ndvi_40[,1:3])
g2
plot(g2)
## multiple variables including continuous variables
discmethod<-c("equal","natural","quantile","geometric","sd")
discitv <- c(3:7)
data.ndvi <- ndvi_40
data.continuous <- data.ndvi[, c(1, 4:7)]
odc1 <- optidisc(NDVIchange ~ ., data = data.continuous, discmethod, discitv) # ~14s
data.continuous <- do.call(cbind, lapply(1:4, function(x)
data.frame(cut(data.continuous[, -1][, x], unique(odc1[[x]]$itv), include.lowest = TRUE))))
# add stratified data to explanatory variables
data.ndvi[, 4:7] <- data.continuous
g3 <- gd(NDVIchange ~ ., data = data.ndvi)
g3
plot(g3)
图 4. 因子探测器结果
风险探测器: riskmean 和 gdrisk
解释变量的风险均值:
## categorical explanatory variables
rm1 <- riskmean(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
rm1
plot(rm1)
## multiple variables inclusing continuous variables
rm2 <- riskmean(NDVIchange ~ ., data = data.ndvi)
rm2
plot(rm2)
风险矩阵:
## categorical explanatory variables
gr1 <- gdrisk(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
gr1
plot(gr1)
## multiple variables inclusing continuous variables
gr2 <- gdrisk(NDVIchange ~ ., data = data.ndvi)
gr2
plot(gr2)
图 5. 风险探测器结果
交互探测器: gdinteract
## categorical explanatory variables
gi1 <- gdinteract(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
gi1
## multiple variables inclusing continuous variables
gi2 <- gdinteract(NDVIchange ~ ., data = data.ndvi)
gi2
plot(gi2)
图 6. 交互探测器结果
生态探测器: gdeco
## categorical explanatory variables
ge1 <- gdeco(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
ge1
## multiple variables inclusing continuous variables
gd3 <- gdeco(NDVIchange ~ ., data = data.ndvi)
gd3
plot(gd3)
图 7. 生态探测器结果
5. 空间尺度影响分析
ndvilist <- list(ndvi_20, ndvi_30, ndvi_40, ndvi_50)
su <- c(20,30,40,50) ## sizes of spatial units
## "gdm" function
gdlist <- lapply(ndvilist, function(x){
gdm(NDVIchange ~ Climatezone + Mining + Tempchange + GDP, continuous_variable = c("Tempchange", "GDP"),
data = x, discmethod = "quantile", discitv = 6)
})
sesu(gdlist, su) ## size effects of spatial units
图 8. 空间尺度影响分析结果
参考文献
Song Y, Wang J, Ge Y and Xu C (2020) “An optimal parameters-based geographical detector model enhances geographic characteristics of explanatory variables for spatial heterogeneity analysis: Cases with different types of spatial data.” GIScience & Remote Sensing, 57(5), pp. 593-610. doi: 10.1080/15481603.2020.1760434.
Wang J, Li X, Christakos G, Liao Y, Zhang T, Gu X and Zheng X (2010). “Geographical Detectors-Based Health Risk Assessment and its Application in the Neural Tube Defects Study of the Heshun Region, China.” International Journal of Geographical Information Science, 24(1), pp. 107-127. doi: 10.1080/13658810802443457.
Wang J, Zhang T and Fu B (2016). “A measure of spatial stratified heterogeneity.” Ecological Indicators,67,pp.250-256.doi: 10.1016/j.ecolind.2016.02.052.
排版:张永红
责任编辑:王佳雯
审编:鲁嘉颐
终审: 顾伟男 田巍 梁龙武
猜你喜欢
2.期刊目录 | Journal of Geovisualization and Spatial Analysis 第4卷第1期目录
扫描二维码,关注我们
都看到这里了,点个【在看】再走呗~