[R] How to real multiple raster and serial correlation between series of rasters

Waseem Ali w1malik at hotmail.com
Sun May 29 20:39:18 CEST 2016




Hi,
I have 120 raster (10 years) files
in tif format of one variable (say X1) and same numbers for second variables (Say
X2). Each raster consists the mean monthly values of corresponding variables. I
want to write a script in R which operates the following operations:

·        
First reads the one by one
raster from folder and save into the objects. 

·        
Resample/aggregate the both
raster over same spatial resolution 2˚ x 2.5˚.

·        
After resampling the all
raster over same resolution, conversions of all raster to points by using the
rasterToPoint() function of raster library.

·        
After retrieving the same
monthly raster values (like month of January for X1 and X2) into data frame, I
want to compute regression and correlation values for all 120 raster for both
variables (X1 and X2) and save into the data frame.

Is there any way out to deal with
such task.


library(raster)

x <- list.files("C:/site-download/",
pattern = "*.tif", full.names = TRUE)

x1 <- raster(x1)

p <- as(x1, 'SpatialPixels')

plot(x1)

points(p)
Resultant figure has been attached for you for only x1 variable. I have also attached the X1 and X2 variable tif raster for January 2002 for computation purpose. I need to operate it through loop for reading all these rasters and computing the correlation of each pairs. My next step to compute the Lag -1 correlations which is Serial Correlation for both variables.
Waseem Ali 
 		 	   		  


More information about the R-help mailing list