import library
library(raster)
## Loading required package: sp
library(ggExtra)
library(spatialEco)
## spatialEco 0.1-5
## Type se.news() to see new features/changes/bug fixes.
Read tif File
worldclim<-raster("worldclim_tw.tif")
chelsa<- raster("Chelsa_tw.tif")
worldclim ## worldclim information
## class : RasterLayer
## dimensions : 517, 769, 397573 (nrow, ncol, ncell)
## resolution : 0.008337745, 0.008331238 (x, y)
## extent : 117.8741, 124.2859, 21.47609, 25.78334 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## data source : F:\R_project\worldclim_chelsa_climate_compare\worldclim_tw.tif
## names : worldclim_tw
## values : -4.4, 15.8 (min, max)
chelsa ## worldclim information
## class : RasterLayer
## dimensions : 517, 769, 397573 (nrow, ncol, ncell)
## resolution : 0.008337745, 0.008331238 (x, y)
## extent : 117.8741, 124.2859, 21.47609, 25.78334 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## data source : F:\R_project\worldclim_chelsa_climate_compare\Chelsa_tw.tif
## names : Chelsa_tw
## values : -4.721886, 13.61559 (min, max)
temperation condition of Taiwan
par(mfrow=c(1,2))
plot(chelsa,main="chelsa Jan tmin")
plot(worldclim,main="worldclim Jan tmin")

difference of temperation condition of Taiwan
difference<- overlay(chelsa,
worldclim,
fun=function(chelsa,worldclim){return(chelsa-worldclim)})
plot(difference,main="chelsa - worldclim Tmin")

histogram of temperation condition of Taiwan
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
hist(difference,
col="springgreen4",
main="Histogram of the difference Tmin between chelsa & worldclim",
ylab="Number of Pixels",
xlab="Temperature")
hist(worldclim,main="Histogram of worldclim January Tmin",xlab="Temperature",ylab="Number of Pixels")
## Warning in sampleInt(length(x), size): size changed to n because it cannot
## be larger than n when replace is FALSE
## Warning in .hist1(x, maxpixels = maxpixels, main = main, plot = plot, ...):
## 25% of the raster cells were used (of which 54% were NA). 45944 values
## used.
hist(chelsa,main="Histogram of chelsa January Tmin",xlab="Temperature",ylab="Number of Pixels")
## Warning in sampleInt(length(x), size): size changed to n because it cannot
## be larger than n when replace is FALSE
## Warning in .hist1(x, maxpixels = maxpixels, main = main, plot = plot, ...):
## 25% of the raster cells were used (of which 54% were NA). 46120 values
## used.

correlation of temperation condition of Taiwan
r.cor<-rasterCorrelation(worldclim,chelsa,s = 5, type = "pearson")
plot(r.cor)

worldclim<-raster("worldclim_v9.tif")
chelsa<- raster("Chelsa_v5.tif")
worldclim ## worldclim information
## class : RasterLayer
## dimensions : 1167, 1407, 1641969 (nrow, ncol, ncell)
## resolution : 0.008332632, 0.008334438 (x, y)
## extent : 96.86063, 108.5846, 25.26633, 34.99262 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## data source : F:\R_project\worldclim_chelsa_climate_compare\worldclim_v9.tif
## names : worldclim_v9
chelsa ## worldclim information
## class : RasterLayer
## dimensions : 1167, 1407, 1641969 (nrow, ncol, ncell)
## resolution : 0.008332632, 0.008334438 (x, y)
## extent : 96.86063, 108.5846, 25.26633, 34.99262 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## data source : F:\R_project\worldclim_chelsa_climate_compare\Chelsa_v5.tif
## names : Chelsa_v5
temperation condition of Sichuan
par(mfrow=c(1,2))
plot(chelsa,main="chelsa Jan tmin")
plot(worldclim,main="worldclim Jan tmin")

difference of temperation condition of Sichuan
difference<- overlay(chelsa,
worldclim,
fun=function(chelsa,worldclim){return(chelsa-worldclim)})
plot(difference,main="chelsa - worldclim Tmin")

histogram of temperation condition of Sichuan
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
hist(difference,
col="springgreen4",
main="Histogram of the difference Tmin between chelsa & worldclim",
ylab="Number of Pixels",
xlab="Temperature")
hist(worldclim,main="Histogram of worldclim January Tmin",xlab="Temperature",ylab="Number of Pixels")
## Warning in .hist1(x, maxpixels = maxpixels, main = main, plot = plot, ...):
## 6% of the raster cells were used. 100000 values used.
hist(chelsa,main="Histogram of chelsa January Tmin",xlab="Temperature",ylab="Number of Pixels")
## Warning in .hist1(x, maxpixels = maxpixels, main = main, plot = plot, ...):
## 6% of the raster cells were used. 100000 values used.

correlation of temperation condition of Sichuan
r.cor<-rasterCorrelation(worldclim,chelsa,s = 5, type = "pearson")
plot(r.cor)
