I'm downloading an average temperature from WorldClim for a set of specific locations (lat-long) using getData
from raster
package. The raw values are around 100. Then I apply gain()
of 0.1 to all of them and R returns values of 1.0, while it should be 10.0. The problem applies only to WorldClim resolution 10 degrees (at 2.5 the temperature values are correct).
Here's what I'm doing:
library(raster)
library(sp)
Some random data
x <- runif(10, -72.85, -72.78)
y <- runif(10, 44.5, 44.6)
coords <- data.frame(x, y)
Downloading WorldClim data, applying gain of 0.1, binding lat-long and climate data in one data frame
r <- getData("worldclim",var="tmean",res=10)
gain(r) <- 0.1
points <- SpatialPoints(coords, proj4string = r@crs)
values <- extract(r,points)
df <- cbind.data.frame(coordinates(points),values)
Does anyone know why gain 0.1 changes 100 into 1.0 instead of 10.0?
Cheers