This file contains hidden or 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
| # Script to test basic handling of raster images with distributedR. Loads | |
| # imagery from a Vertica database. | |
| # | |
| # Alex Zvoleff, azvoleff@conservation.org, July 2014 | |
| library(distributedR) | |
| library(vRODBC) | |
| Sys.setenv(VERTICAINI="/home/alexz/vertica.ini") | |
| Sys.setenv(ODBCINI="/home/alexz/odbc.ini") | |
| #distributedR_start() |
This file contains hidden or 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
| library(raster) | |
| library(stringr) | |
| img_file <- 'PSH_mosaic_2010_predictors.tif' | |
| img <- stack(img_file) | |
| img <- setMinMax(img) | |
| # Setup a list with metadata on the image. | |
| img_meta <- list(site=str_extract(img_file, '^[a-zA-Z]*'), |
This file contains hidden or 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
| library(foreach) | |
| library(doParallel) | |
| # In the call below, 2 is the number of cores to use - set this to be less than | |
| # the total number of cores you have. | |
| cl <- makeCluster(2) | |
| results <- foreach(i=1:5, .packages=c('pkg1', 'pkg2')) %dopar% { | |
| # Do some stuff in here, and save the results in "results" |
NewerOlder