[Solved] Correlation between points and raster

user2543 Asks: Correlation between points and raster
I have a set of rasters (NDVI001.tif…NDVI200.tif) and I want to correlate these with overlain time series observed soil moisture.

This link suggests to extract point from the raster and do it graphically in Excel: I believe it can be done it R; I just do not know how.

library (gstat)
r<- raster ()

NDVI <- stack(list.files(path = userpath, pattern = 'NDVI*.*.tif',full.names = T))
Soil<-readOGR('C:\somepath\file.shp', 'file')

I am stuck here. I do not know how to continue. The shp has field values similar to the dates of NDVI001…200.tif.

corvalues,-vector (mode='numeric')

for (i in 1:dim(NDVI)[1]{
corValues[i] <- cor(x = NDVItemp[i,], y = Soil[i,], method = **'pearson'**)

correlationRaster <- setValues(NDVI[[1]], values = corValues)
plot(correlationRaster, xlab='latitude', ylab='longitude', main="NDVI vs Soil")

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.