Search code examples
rraster

Extract function of raster package gives incorrect values from Chelsa layers


I made a stack of Chelsa climatic layers (1981 - 2010; bioclimatic layers), and tried to extract values using occurrence records. But, I am getting wrong values.

Loading rasters

library (raster)
library (sp)

layers <- list.files(path = "C:/Users/DELL/OneDrive/Documents", 
                      pattern='.tif$', all.files= T, full.names= TRUE)
allrasters <- lapply(layers, raster)
bio_layers<-stack(allrasters)

nr

longitude latitude
-58.93127 -34.19912
-58.86730 -33.4797
-60.64690 -32.0161
-60.16690 -32.635
-60.57160 -31.67717
-57.51700 -25.335

coordinates(nr)<-c("longitude", "latitude")
ex<-extract(bio_layers[[1]], nr, df = T)

ex

1 2900
2 2908
3 2917
4 2913
5 2918
6 2956

The result that I showed here is for annual mean temperature (bio1). These values are not correct. When I use QGIS for extracting values, it works well. May I know where I am going wrong ???


Solution

  • The extracted values are perfectly right. I have seen the CHELSA V2.1: Technical specification, 7.1. Climatologies. The values are scaled. So, inorder to have the correct values, you have to do

    bio1 = bio_layers[[1]]*0.1-273.15
    

    If I do it, then the values will be

    1 16.85
    2 17.65
    3 18.55
    4 18.15
    5 18.65
    6 22.45