利用R提取海拔、温度和降水等信息

全球范围内的温度降水等信息, 常用于物种潜在分布区预测研究中。与此同时,在生态学研究中,常需要某些地点的温度降水等信息。 较早公开的较高精度的气候数据,包括Worldclim(http://www.worldclim.org/)。 2017年,另一套高精度数据CHELSA (Climatologies at high resolution for the earth’s land surface areas, http://chelsa-climate.org/) 公开发布。 CHELSA数据整合了局域尺度的降雨等信息, 部分气象因子比Worldclim更准确。 同一年,Worldclimate也发布了2.0版本。

已知某些地点的经纬度,要提取这些地点的温度降水等信息,用DIVA-GIS(http://www.diva-gis.org/ ) 和Worldclim数据很容易做到, 具体方法参见 http://blog.sciencenet.cn/blog-255662-679159.html

不过由于DIVA-GIS是依靠鼠标操作,很难批量化处理。 本文给出提取气候数据的R代码。相关操作主要基于Robert Hijmans的raster程序包, 更多详细信息请参考 (http://rspatial.org/index.html)

海拔数据下载
http://edcintl.cr.usgs.gov/downloads/sciweb1/shared/topo/downloads/GMTED/Grid_ZipFiles/mn30_grd.zip

CHELSA提供的19个Bioclimate 数据下载
https://www.wsl.ch/lud/chelsa/data/bioclim/integer/

各环境变量
Bio1 = Annual Mean Temperature 年均温

Bio2 = Mean Diurnal Range,即 Mean of monthly (max temp - min temp) 平均月温差

Bio3 = Isothermality 等温性

Bio4 = Temperature Seasonality 温度的季节性

Bio5 = Max Temperature of Warmest Month 最暖月最高温

Bio6 = Min Temperature of Coldest Month 最冷月最低温

Bio7 = Temperature Annual Range 气温年较差

Bio8 = Mean Temperature of Wettest Quarter 最湿季均温

Bio9 = Mean Temperature of Driest Quarter 最干季均温

Bio10 = Mean Temperature of Warmest Quarter 最暖月均温

Bio11 = Mean Temperature of Coldest Quarter 最冷月均温

Bio12 = Annual Precipitation 年降水

Bio13 = Precipitation of Wettest Month 最湿润月降水

Bio14 = Precipitation of Driest Month 最干旱月降水

Bio15 = Precipitation Seasonality 气温的季节性

Bio16 = Precipitation of Wettest Quarter 最湿润季降水

Bio17 = Precipitation of Driest Quarter 最干旱季降水

Bio18 = Precipitation of Warmest Quarter 最暖季降水

Bio19 = Precipitation of Coldest Quarter 最冷季降水

CHELSA气候图层, 选择整数还是浮点数图层?
可选择整数图层 integer ,这是因为整数图层占用空间较小, 同时也有相对较高的精度, 如温度可精确到0.1度。 注意,这里的温度是*10的值, 也就说,某地年均温为15.2度, 则提取出的数值为152。

30s数据能达到什么精度?
edge.length <- 63782pi1000/(36060*60)*30
edge.length
表明最大栅格边长约为928米。

计算对角线长度
edge.length *1.414

[1] 1311.686

所以如果两个地点相距不足1312m, 那么两个点有可能落在同一个栅格内, 那么提取的气候要素也就没有任何区别。

图层用的是什么投影?
所有图层都使用WGS1984投影, 用于提取数据的坐标, 也必须是WGS1984坐标

解压缩
下载的7z文件用 7-Zip(https://www.7-zip.org/

R代码

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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
setwd("C:/Users/jlzhang/Desktop/CHELSA")
library(raster)
## Loading required package: sp
library(openxlsx)
#### locations <- read.csv("https://simplemaps.com/static/data/world-cities/basic/simplemaps-worldcities-basic.csv", header = TRUE)
#### write.csv(locations, "locations.csv")
locations <- read.csv("locations.csv")
locations30 <- locations[sample(1:nrow(locations), 30),]
colnames(locations30)
## [1] "X" "city" "city_ascii" "lat" "lng"
## [6] "pop" "country" "iso2" "iso3" "province"
locations30
## X city city_ascii lat lng
## 3081 3081 Bhagalpur Bhagalpur 25.229996 86.98000321
## 6838 6838 Homer Homer 59.642934 -151.54827970
## 7257 7257 Lahij Lahij 13.058181 44.88376135
## 1214 1214 Dori Dori 14.033997 -0.02799852
## 6716 6716 Douglas Douglas 31.507778 -82.85068994
## 4313 4313 Bluefields Bluefields 11.999977 -83.76494938
## 1743 1743 Fuyang Fuyang 32.900407 115.82000000
## 6831 6831 Ambler Ambler 67.086485 -157.85140910
## 6249 6249 Southampton Southampton 50.900031 -1.39997685
## 4920 4920 Vladikavkaz Vladikavkaz 43.050381 44.66997595
## 5423 5423 Al Mubarraz Al Mubarraz 25.429054 49.56590450
## 5784 5784 Schaffhausen Schaffhausen 47.706003 8.63299852
## 1304 1304 Creston Creston 49.099960 -116.51669700
## 7110 7110 Guliston Guliston 40.495731 68.79072587
## 5309 5309 Pervouralsk Pervouralsk 56.910026 59.95503780
## 6658 6658 Woodward Woodward 36.433421 -99.39769027
## 1405 1405 Cochrane Cochrane 49.067017 -81.01656417
## 7264 7264 Sayhut Sayhut 15.210504 51.24544023
## 187 187 Troll Station Troll Station -72.016290 2.53332312
## 7034 7034 Cincinnati Cincinnati 39.161885 -84.45692265
## 4395 4395 Sokoto Sokoto 13.060015 5.24003129
## 3078 3078 Lucknow Lucknow 26.855039 80.91499874
## 3877 3877 Tidjikdja Tidjikdja 18.550016 -11.41660059
## 4130 4130 Rabat Rabat 34.025299 -6.83613082
## 7000 7000 Montgomery Montgomery 32.361602 -86.27918868
## 1990 1990 Bose Bose 23.899716 106.61332680
## 6893 6893 Kalispell Kalispell 48.197767 -114.31597860
## 3587 3587 Rudny Rudny 52.952697 63.13003780
## 1030 1030 Mineiros Mineiros -17.569536 -52.55998071
## 3114 3114 Padangsidempuan Padangsidempuan 1.388738 99.27336137
## pop country iso2 iso3
## 3081 361548.0 India IN IND
## 6838 5021.5 United States of America US USA
## 7257 44831.5 Yemen YE YEM
## 1214 37806.0 Burkina Faso BF BFA
## 6716 12159.0 United States of America US USA
## 4313 40033.0 Nicaragua NI NIC
## 1743 170023.0 China CN CHN
## 6831 258.0 United States of America US USA
## 6249 384417.0 United Kingdom GB GBR
## 4920 341000.0 Russia RU RUS
## 5423 294682.0 Saudi Arabia SA SAU
## 5784 33863.0 Switzerland CH CHE
## 1304 4816.0 Canada CA CAN
## 7110 74446.5 Uzbekistan UZ UZB
## 5309 127236.0 Russia RU RUS
## 6658 12339.5 United States of America US USA
## 1405 4441.0 Canada CA CAN
## 7264 189.0 Yemen YE YEM
## 187 25.5 Antarctica AQ ATA
## 7034 971191.0 United States of America US USA
## 4395 648019.5 Nigeria NG NGA
## 3078 2583505.5 India IN IND
## 3877 19981.0 Mauritania MR MRT
## 4130 1680376.5 Morocco MA MAR
## 7000 194491.5 United States of America US USA
## 1990 132942.5 China CN CHN
## 6893 25040.0 United States of America US USA
## 3587 104235.5 Kazakhstan KZ KAZ
## 1030 28247.0 Brazil BR BRA
## 3114 183721.5 Indonesia ID IDN
## province
## 3081 Bihar
## 6838 Alaska
## 7257 Lahij
## 1214 Séno
## 6716 Georgia
## 4313 Atlántico Sur
## 1743 Anhui
## 6831 Alaska
## 6249 Southampton
## 4920 North Ossetia
## 5423 Ash Sharqiyah
## 5784 Schaffhausen
## 1304 British Columbia
## 7110 Sirdaryo
## 5309 Sverdlovsk
## 6658 Oklahoma
## 1405 Ontario
## 7264 Al Mahrah
## 187
## 7034 Ohio
## 4395 Sokoto
## 3078 Uttar Pradesh
## 3877 Tagant
## 4130 Rabat - Salé - Zemmour - Zaer
## 7000 Alabama
## 1990 Guangxi
## 6893 Montana
## 3587 Qostanay
## 1030 Goiás
## 3114 Sumatera Utara
coordinates(locations30) = c("lng","lat") # specify column names
### 年均温
bio1 <- raster("CHELSA_bio10_1.tif")
plot(bio1, main="Annual Mean Temperature",
xlab="Longitude", ylab="Latitude", col=rev(heat.colors(100)))
img

res_bio1 <- extract(x = bio1, y = locations30)


### 海拔
elevation <- raster("mn30_grd")
plot(elevation, main="Altitude",
xlab="Longitude", ylab="Latitude",col= terrain.colors(100))
img

res_elevation <- extract(x = elevation, y = locations30)

res <- data.frame(locations30, res_bio1, res_elevation)
res
## X city city_ascii lat lng
## 3081 3081 Bhagalpur Bhagalpur 25.229996 86.98000321
## 6838 6838 Homer Homer 59.642934 -151.54827970
## 7257 7257 Lahij Lahij 13.058181 44.88376135
## 1214 1214 Dori Dori 14.033997 -0.02799852
## 6716 6716 Douglas Douglas 31.507778 -82.85068994
## 4313 4313 Bluefields Bluefields 11.999977 -83.76494938
## 1743 1743 Fuyang Fuyang 32.900407 115.82000000
## 6831 6831 Ambler Ambler 67.086485 -157.85140910
## 6249 6249 Southampton Southampton 50.900031 -1.39997685
## 4920 4920 Vladikavkaz Vladikavkaz 43.050381 44.66997595
## 5423 5423 Al Mubarraz Al Mubarraz 25.429054 49.56590450
## 5784 5784 Schaffhausen Schaffhausen 47.706003 8.63299852
## 1304 1304 Creston Creston 49.099960 -116.51669700
## 7110 7110 Guliston Guliston 40.495731 68.79072587
## 5309 5309 Pervouralsk Pervouralsk 56.910026 59.95503780
## 6658 6658 Woodward Woodward 36.433421 -99.39769027
## 1405 1405 Cochrane Cochrane 49.067017 -81.01656417
## 7264 7264 Sayhut Sayhut 15.210504 51.24544023
## 187 187 Troll Station Troll Station -72.016290 2.53332312
## 7034 7034 Cincinnati Cincinnati 39.161885 -84.45692265
## 4395 4395 Sokoto Sokoto 13.060015 5.24003129
## 3078 3078 Lucknow Lucknow 26.855039 80.91499874
## 3877 3877 Tidjikdja Tidjikdja 18.550016 -11.41660059
## 4130 4130 Rabat Rabat 34.025299 -6.83613082
## 7000 7000 Montgomery Montgomery 32.361602 -86.27918868
## 1990 1990 Bose Bose 23.899716 106.61332680
## 6893 6893 Kalispell Kalispell 48.197767 -114.31597860
## 3587 3587 Rudny Rudny 52.952697 63.13003780
## 1030 1030 Mineiros Mineiros -17.569536 -52.55998071
## 3114 3114 Padangsidempuan Padangsidempuan 1.388738 99.27336137
## pop country iso2 iso3
## 3081 361548.0 India IN IND
## 6838 5021.5 United States of America US USA
## 7257 44831.5 Yemen YE YEM
## 1214 37806.0 Burkina Faso BF BFA
## 6716 12159.0 United States of America US USA
## 4313 40033.0 Nicaragua NI NIC
## 1743 170023.0 China CN CHN
## 6831 258.0 United States of America US USA
## 6249 384417.0 United Kingdom GB GBR
## 4920 341000.0 Russia RU RUS
## 5423 294682.0 Saudi Arabia SA SAU
## 5784 33863.0 Switzerland CH CHE
## 1304 4816.0 Canada CA CAN
## 7110 74446.5 Uzbekistan UZ UZB
## 5309 127236.0 Russia RU RUS
## 6658 12339.5 United States of America US USA
## 1405 4441.0 Canada CA CAN
## 7264 189.0 Yemen YE YEM
## 187 25.5 Antarctica AQ ATA
## 7034 971191.0 United States of America US USA
## 4395 648019.5 Nigeria NG NGA
## 3078 2583505.5 India IN IND
## 3877 19981.0 Mauritania MR MRT
## 4130 1680376.5 Morocco MA MAR
## 7000 194491.5 United States of America US USA
## 1990 132942.5 China CN CHN
## 6893 25040.0 United States of America US USA
## 3587 104235.5 Kazakhstan KZ KAZ
## 1030 28247.0 Brazil BR BRA
## 3114 183721.5 Indonesia ID IDN
## province optional res_bio1 res_elevation
## 3081 Bihar TRUE 252 44
## 6838 Alaska TRUE 46 56
## 7257 Lahij TRUE 294 128
## 1214 Séno TRUE 290 281
## 6716 Georgia TRUE 185 81
## 4313 Atlántico Sur TRUE 266 5
## 1743 Anhui TRUE 158 34
## 6831 Alaska TRUE -46 34
## 6249 Southampton TRUE 109 6
## 4920 North Ossetia TRUE 103 663
## 5423 Ash Sharqiyah TRUE 273 155
## 5784 Schaffhausen TRUE 100 446
## 1304 British Columbia TRUE 88 622
## 7110 Sirdaryo TRUE 163 273
## 5309 Sverdlovsk TRUE 20 329
## 6658 Oklahoma TRUE 146 592
## 1405 Ontario TRUE 16 276
## 7264 Al Mahrah TRUE 283 10
## 187 TRUE -212 1242
## 7034 Ohio TRUE 126 193
## 4395 Sokoto TRUE 285 291
## 3078 Uttar Pradesh TRUE 251 128
## 3877 Tagant TRUE 283 409
## 4130 Rabat - Salé - Zemmour - Zaer TRUE 193 22
## 7000 Alabama TRUE 183 88
## 1990 Guangxi TRUE 223 137
## 6893 Montana TRUE 78 903
## 3587 Qostanay TRUE 39 145
## 1030 Goiás TRUE 229 769
## 3114 Sumatera Utara TRUE 250 325
write.xlsx(res, "extracted.xlsx")