-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenviromental preparetion.R
241 lines (193 loc) · 12.6 KB
/
enviromental preparetion.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
library(maptools)
library(rgeos)
library(raster)
library(rgdal)
library(sp)
library(rgbif)
library(rJava)
library(readxl)
library(mapview)
library(ggplot2)
library(jsonlite)
require(sf)
library(devtools)
library(xlsx)
extend.asia <- extent(c(2777000, 17260000, -1646000, 5210000))
SR.ORG8287 <- CRS('+proj=cea +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs') #define the project
#climate data
#current
# memory.limit(size = 1000000)#setup memorry limit
latlong <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
SR.ORG8287 <- CRS('+proj=cea +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
extent.asia.latlon <- extent(c(25, 152, -10, 56))
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/1981-2010/CHELSA_bio',i,'_1981-2010_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/current/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#2050s
latlong <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
SR.ORG8287 <- CRS('+proj=cea +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
extent.asia.latlon <- extent(c(25, 152, -10, 56))
#GFDL_ESM4
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/GFDL-ESM4/ssp370/CHELSA_bio',i,'_2041-2070_gfdl-esm4_ssp370_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/GFDL-/ssp370/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#IPSL-CM6A-LR
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/IPSL-CM6A-LR/ssp370/CHELSA_bio',i,'_2041-2070_ipsl-cm6a-lr_ssp370_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/IPSL-CM6A-LR/ssp370/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#MPI-ESM1-2-HR
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/MPI-ESM1-2-HR/ssp370/CHELSA_bio',i,'_2041-2070_mpi-esm1-2-hr_ssp370_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/MPI-ESM1-2-HR/ssp370/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#MRI-ESM2-0
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/MRI-ESM2-0/ssp370/CHELSA_bio',i,'_2041-2070_mri-esm2-0_ssp370_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/MRI-ESM2-0/ssp370/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#UKESM1-0-LL
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/UKESM1-0-LL/ssp370/CHELSA_bio',i,'_2041-2070_ukesm1-0-ll_ssp370_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/UKESM1-0-LL/ssp370/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#2050s SSP585
latlong <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
SR.ORG8287 <- CRS('+proj=cea +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
extent.asia.latlon <- extent(c(25, 152, -10, 56))
#GFDL_ESM4
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/GFDL-ESM4/ssp585/CHELSA_bio',i,'_2041-2070_gfdl-esm4_ssp585_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/GFDL-ESM4/ssp585/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#IPSL-CM6A-LR
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/IPSL-CM6A-LR/ssp585/CHELSA_bio',i,'_2041-2070_ipsl-cm6a-lr_ssp585_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/IPSL-CM6A-LR/ssp585/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#MPI-ESM1-2-HR
for(i in 1:19){
climate <- raster(paste0('F:/GIS_data/Chelsa_ver_2/2041-2070/MPI-ESM1-2-HR/ssp585/CHELSA_bio',i,'_2041-2070_mpi-esm1-2-hr_ssp585_V.2.1.tif'))
crs(climate) <- latlong
climate <- crop(climate, extent.asia.latlon)
climate <- projectRaster(climate, crs = SR.ORG8287, res = 1000, method = 'bilinear')
writeRaster(climate, filename = paste0('F:/Working/2018/PhD_research/enviromental_variables_new/2050/MPI-ESM1-2-HR/ssp585/bio',i,'.tif'), format="GTiff", overwrite=T)
print(i)
}
#kart data
bio1 <- raster('F:/Working/2018/PhD_research/enviromental_variables_new/current/bio1.tif')
karst <- readOGR('F:/GIS_data/enviromental/karst/karst_wgs.shp')
karst_reproj <- spTransform(karst, CRSobj = raster::crs(bio1))
karst_asia <- crop(karst_reproj, extent(bio1))
karst_raster <- rasterize(karst_asia, bio1, field = 1, background=0)
# karst_crop <- crop(karst, bio1)
writeRaster(karst_raster, filename = "F:/Working/2018/PhD_research/enviromental_variables_new/current/karst.tif", format="GTiff", overwrite=T)
#ESA landcover 2018
# bio <- getData('worldclim', var='bio', res=0.5, lon=105, lat=20)
# vn <- getData('GADM', country='VN', level = 0)
landcover_2018 <- raster('F:/GIS_data/Global landcover/ESA_CCI_Landcover_2018/esa_cci_landcover_2018_asia.tif')
landcover_2018_reproj <- projectRaster(landcover_2018, crs = SR.ORG8287)
writeRaster(landcover_2018_reproj, filename = 'F:/GIS_data/Global landcover/ESA_CCI_Landcover_2018/esa_cci_landcover_2018_asia_SRORG8287.tif', format='GTiff', overwrite = T)
landcover_2050 <- raster('F:/GIS_data/Global landcover/ESA_CCI_Landcover_2050/Land_Cover_Projection_2050_asia.tif')
landcover_2050_reproj <- projectRaster(landcover_2050, crs = SR.ORG8287)
writeRaster(landcover_2050_reproj, filename = 'F:/GIS_data/Global landcover/ESA_CCI_Landcover_2050/Land_Cover_Projection_2050_asia_SRORG8287.tif', format='GTiff', overwrite = T)
landcover_2018 <- raster('F:/GIS_data/Global landcover/ESA_CCI_Landcover_2018/esa_cci_landcover_2018_asia_SRORG8287.tif')
bio1 <- raster('F:/Working/2018/PhD_research/enviromental_variables_new/current/bio1.tif')
# landcover_2018_crop <- crop(landcover_2018,bio1)
cropland <- landcover_2018==1
cropland_agg <- aggregate(cropland, 3, fun='sum')/9*100
cropland_resample <- raster::resample(cropland_agg,bio1,method='bilinear')
cropland_resample_crop <- raster::crop(cropland_resample,bio1)
grassland_scrub <- landcover_2018==2
grassland_scrub_agg <- aggregate(grassland_scrub, 3, fun='sum')/9*100
grassland_scrub_resample <- raster::resample(grassland_scrub_agg,bio1, method='bilinear')
grassland_scrub_resample_crop <- raster::crop(grassland_scrub_resample,bio1
)
decidous_forest <- landcover_2018==3
decidous_forest_agg <- aggregate(decidous_forest, 3, fun='sum')/9*100
decidous_forest_resample <- raster::resample(decidous_forest_agg,bio1,method='bilinear')
decidous_forest_resample_crop <- raster::crop(decidous_forest_resample,bio1)
evergreen_forest <- landcover_2018==4
evergreen_forest_agg <- aggregate(evergreen_forest, 3, fun='sum')/9*100
evergreen_forest_resample <- raster::resample(evergreen_forest_agg,bio1, method='bilinear')
evergreen_forest_resample_crop <- raster::crop(evergreen_forest_resample,bio1)
flooded_vegetation <- landcover_2018==7
flooded_vegetation_agg <- aggregate(flooded_vegetation, 3, fun='sum')/9*100
flooded_vegetation_resample <- raster::resample(flooded_vegetation_agg,bio1,method='bilinear')
flooded_vegetation_resample_crop <- raster::crop(flooded_vegetation_resample,bio1)
urban <- landcover_2018==8
urban_agg <- aggregate(urban, 3, fun='sum')/9*100
urban_resample <- raster::resample(urban_agg,bio1,method='bilinear')
urban_resample_cop <- raster::crop(urban_resample,bio1)
writeRaster(cropland_resample_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/cropland.tif', format='GTiff', overwrite = T)
writeRaster(grassland_scrub_resample_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/grassland_scrub.tif', format='GTiff', overwrite = T)
writeRaster(decidous_forest_resample_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/decidous_forest.tif', format='GTiff', overwrite = T)
writeRaster(evergreen_forest_resample_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/evergreen_forest.tif', format='GTiff', overwrite = T)
writeRaster(flooded_vegetation_resample_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/flooded_vegetation.tif', format='GTiff', overwrite = T)
writeRaster(urban_resample_cop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/current/urban.tif', format='GTiff', overwrite = T)
landcover_2050 <- raster('F:/GIS_data/Global landcover/ESA_CCI_Landcover_2050/Land_Cover_Projection_2050_asia_SRORG8287.tif')
bio1 <- raster('F:/Working/2018/PhD_research/enviromental_variables_new/current/bio1.tif')
cropland <- landcover_2050==1
cropland_agg <- aggregate(cropland, 3, fun='sum')/9*100
cropland_resample <- resample(cropland_agg,bio1,method='bilinear')
cropland_crop <- crop(cropland_resample,bio1)
grassland_scrub <- landcover_2050==2
grassland_scrub_agg <- aggregate(grassland_scrub, 3, fun='sum')/9*100
grassland_scrub_resample <- resample(grassland_scrub_agg,bio1,method='bilinear')
grassland_scrub_crop <- crop(grassland_scrub_resample,bio1)
decidous_forest <- landcover_2050==3
decidous_forest_agg <- aggregate(decidous_forest, 3, fun='sum')/9*100
decidous_forest_resample <- resample(decious_forest_agg,bio1,method='bilinear')
decidous_forest_crop <- crop(decidous_forest_resample,bio1)
evergreen_forest <- landcover_2050==4
evergreen_forest_agg <- aggregate(evergreen_forest, 3, fun='sum')/9*100
evergreen_forest_resample <- resample(evergreen_forest_agg,bio1,method='bilinear')
evergreen_forest_crop <- crop(evergreen_forest_resample,bio1)
flooded_vegetation <- landcover_2050==7
flooded_vegetation_agg <- aggregate(flooded_vegetation, 3, fun='sum')/9*100
flooded_vegetation_resample <- resample(flooded_vegetation_agg,bio1,method='bilinear')
flooded_vegetation_crop <- crop(flooded_vegetation_resample,bio1)
urban <- landcover_2050==8
urban_agg <- aggregate(urban, 3, fun='sum')/9*100
urban_resample <- resample(urban_agg,bio1,method='bilinear')
urban_crop <- crop(urban_resample,bio1)
writeRaster(cropland_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/cropland.tif', format='GTiff', overwrite = T)
writeRaster(grassland_scrub_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/grassland_scrub.tif', format='GTiff', overwrite = T)
writeRaster(decidous_forest_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/decidous_forest.tif', format='GTiff', overwrite = T)
writeRaster(evergreen_forest_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/evergreen_forest.tif', format='GTiff', overwrite = T)
writeRaster(flooded_vegetation_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/flooded_vegetation.tif', format='GTiff', overwrite = T)
writeRaster(urban_crop, filename = 'F:/Working/2018/PhD_research/enviromental_variables_new/2050/landcover/urban.tif', format='GTiff', overwrite = T)