Last active
December 14, 2015 20:08
-
-
Save xuanlongma/5141275 to your computer and use it in GitHub Desktop.
faster stack raster files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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