[R-sig-Geo] Regional Average of Rasters

Tiffany Smith smithtiffanyt at gmail.com
Tue Nov 11 18:58:36 CET 2014


I have a rasterBrick (temp) with global temperatures, and a rasterLayer (regions) of global regions. I would like to create a rasterBrick of regional average temperatures. So far I have the following:

region1<-mask(temp,regions,maskvalue=1,inverse=TRUE)
mean1<-cellStats(region1,mean)

region2<-mask(temp,regions,maskvalue=2,inverse=TRUE)
mean2<-cellStats(region2,mean)

At which point, I’m not sure how to get this back into raster format. Alternatively, this can’t be the most efficient way to do this - any ideas would be much appreciated.

Thanks,
Tiffany
	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list