SHARE
TWEET

Untitled

a guest Dec 14th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require(raster)
  2. require(rgdal)
  3. require(sp)
  4. require(snow)
  5. setwd("E:/neeraj_pandey/neeraj_pandey/2016")
  6. test=list.files(getwd(), pattern="tif$", full.names=FALSE)
  7. test
  8. NDVI=function(a,b){
  9.   den=a-b
  10.   num=a+b
  11.   nd=den/num
  12.   nd[is.na(nd)]=-999
  13.   return(nd)
  14. }
  15. for(i in c(1,3,5,7,9,11,13,15,17,19,21,23,25,27)){
  16.   red=raster(test[i])
  17.   nir=raster(test[i+1])
  18.   out=overlay(nir,red,fun=NDVI,progress='text')
  19.   outfilename=paste('NDVI',i,sep = ' ')
  20.   writeRaster(out,outfilename,format= 'ENVI')
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top