Quick post on terrain classification, based on some trouble folks were having with a previous example on Windows. With the spgrass6 package, raster stacks are created by loading several GRASS files at once:
x <- readRAST6(vname=c('beam_sum_mj','ned10m_ccurv','ned10m_pcurv','ned10m_slope')). This works well on UNIX-like operating systems and in cases where the entire collection of raster maps can fit within the system memory. A different strategy is needed when working with massive raster stacks or on other (less useful) operating systems. This post outlines one possible strategy that should work on massive data sets, and across operating systems.
- export terrain surfaces from GRASS to intermediate files
- import into R with raster package
- perform unsupervised classification on a sample of the cells using PAM
- apply clustering to unsampled cells with randomForest
- save results to intermediate file
- import results into GRASS for post-processing