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 
                                          
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to