Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require(raster)
- require(rgdal)
- require(sp)
- require(snow)
- setwd("E:/neeraj_pandey/neeraj_pandey/2016")
- test=list.files(getwd(), pattern="tif$", full.names=FALSE)
- test
- NDVI=function(a,b){
- den=a-b
- num=a+b
- nd=den/num
- nd[is.na(nd)]=-999
- return(nd)
- }
- for(i in c(1,3,5,7,9,11,13,15,17,19,21,23,25,27)){
- red=raster(test[i])
- nir=raster(test[i+1])
- out=overlay(nir,red,fun=NDVI,progress='text')
- outfilename=paste('NDVI',i,sep = ' ')
- writeRaster(out,outfilename,format= 'ENVI')
- }
Add Comment
Please, Sign In to add comment