I would like to study the association between categorical rasterised environmental variables in R. Is there any way to do it in R?
The raster package in R is devoted to handle with raster data: https://cran.r-project.org/web/packages/raster/raster.pdf
I'm not quite sure about what do you want to do with your data. Since I assume your rasters contain quantitative data, you can use the function 'layerStats' to get the correlation between two rasters. However, to use it, you must join the raster in a multiband raster using 'stack'. Here is an example written by me:
library(raster) #load the rasters provision <- raster('prov_mask.tif') cultural <- raster('cult_mask.tif') regulating <- raster('regul_mask.tif') #standardize the rasters with same extent and crs cultural <- raster(vals=values(cultural),ext=extent(provision), crs=crs(provision), nrows=dim(provision),ncols=dim(provision)) regulating <- raster(vals=values(regulating),ext=extent(provision), crs=crs(provision), nrows=dim(provision),ncols=dim(provision)) #do the correlation matrix among the three rasters SE <- stack(provision, regulating, cultural) cor.SE <- layerStats(SE, 'pearson', na.rm = TRUE)