# NOT RUN {
library(raster)
dir <- file.path(tmpDir(), 'MODIStest'); dir.create(path = dir)
fileDL <- 'http://e4ftl01.cr.usgs.gov/MOLT/MOD17A2.055/2003.07.12/MOD17A2.A2003193.h19v07.055.2011269202445.hdf'
modis <- file.path(dir, basename(fileDL)); download.file(url = fileDL, destfile = modis)
# Now We've just downloaded a MODIS file that is stored in a subdirectory of the raster tmp directory
sprintf('These data have been acquired around %s', getMODISinfo(modis)$date)
# Clean dataset and replace fill values by NAs
# Product details at https://lpdaac.usgs.gov/products/modis_products_table/mod17a2
MODISclean <- cleanMODIS(x=modis, data_SDS=1, QC_SDS=3, bit=TRUE, QC_val=0x19, fill = (32761:32767))
plot(MODISclean)
# In that case we did not write the result back to disk, but note that this is possible
# For that use the filename= argument, and the datatype= argument (recommended)
# }
Run the code above in your browser using DataLab