First, I managed to extract the average raster temperature values for each polygon, with the following program:
You can download the GIS layers on this link :
https://depots.univ-perp.fr/get?k=iTzEDSUkdyZVw2st78G
## load packages
library(raster); library(rgdal)
## Read rasters
ras_temp<-raster("ras_temp.tif")
plot(ras_temp)
ras_alti<-raster("ras_alti.tif")
## read polygon
polygon <- readOGR(dsn = getwd(), layer = "polygon")
plot(polygon,add=TRUE)
## extract mean value for each polygon
v1 <- extract( ras_temp, polygon, fun=mean, na.rm=TRUE)
nom <- sapply(polygon@polygons, slot, "ID")
v1 <- data.frame(ID = nom, Value = v1)
View(v1)
Then, I want to extract the mean values of the temperature for each polygon but only for the surfaces that exceed 600 m of altitude?
Unfortunately, I can not do it, my question how to integrate the altitude condition in my function "extract"?
Thanks in advance