1 |
7526fb1c
|
Jim Regetz
|
#setwd("/data/project/organisms/R")
|
2 |
|
|
#source("ReClass Clear Day Rasters.r", echo=TRUE, print.eval=TRUE)
|
3 |
|
|
setwd("/data/project/organisms/MODIS_LST_Oregon/ClearDayGDAL")
|
4 |
|
|
outPath = "/data/project/organisms/MODIS_LST_Oregon/ClearDayGDAL/Scaled/"
|
5 |
|
|
library(raster)
|
6 |
|
|
inFiles <- list.files(pattern="*.img$")
|
7 |
|
|
myFiles <- grep("h08v04",substr(inFiles, 18,23))
|
8 |
|
|
nFiles <- length(myFiles)
|
9 |
|
|
inputRaster <- raster()
|
10 |
|
|
for (iCtr in 1 : nFiles)
|
11 |
|
|
{
|
12 |
|
|
message(sprintf("Reading file: %s",inFiles[iCtr]))
|
13 |
|
|
inputRaster <- raster(inFiles[iCtr])
|
14 |
|
|
calcRaster <- inputRaster * 0.0005
|
15 |
|
|
outFile <- substr(inFiles[iCtr],1,36)
|
16 |
|
|
outFile <- trim(outFile)
|
17 |
|
|
outFile <- paste(outFile, "_Scaled.img", sep="")
|
18 |
|
|
outPathFile <- paste(outPath, outFile)
|
19 |
|
|
# Check if file exists and write raster if it does not
|
20 |
|
|
if (file.exists("ReClass Clear Day Rasters.r") == FALSE) {
|
21 |
|
|
message(sprintf("..Recalculating file: %s",outFile))
|
22 |
|
|
writeRaster(calcRaster,filename=outPathFile,format="HFA",overwrite=TRUE)
|
23 |
|
|
}
|
24 |
|
|
}
|