Skip to content

Instantly share code, notes, and snippets.

@xuanlongma
Last active December 14, 2015 20:08
Show Gist options
  • Save xuanlongma/5141275 to your computer and use it in GitHub Desktop.
Save xuanlongma/5141275 to your computer and use it in GitHub Desktop.
faster stack raster files
## Thanks RobertH for sharing this very useful function
## http://stackoverflow.com/a/9937083
fun.quickstack <- function(f) {
r <- raster(f[1])
ln <- extension(basename(f), '')
s <- stack(r)
s@layers <- sapply(1:length(f), function(x){ r@file@name = f[x];
r@layernames=ln[x]; r@data@haveminmax=FALSE ; r })
s@layernames <- ln
s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment