MODISoptions.R 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. #' Set or Retrieve Permanent MODIS Package Options
  2. #'
  3. #' @description
  4. #' Set or retrieve persistant \strong{MODIS} package options (per user or
  5. #' systemwide). Changes here will persist through sessions and updates.
  6. #'
  7. #' @param localArcPath \code{character}, defaults to
  8. #' \code{file.path(tempdir(), "MODIS_ARC")}. Target folder for downloaded MODIS
  9. #' HDF files.
  10. #' @param outDirPath \code{character}, defaults to
  11. #' \code{file.path(tempdir(), "MODIS_ARC/PROCESSED")}. Target folder for results
  12. #' of \code{\link{runGdal}} and \code{\link{runMrt}}.
  13. #' @param pixelSize Output pixel size (in target reference system units) passed
  14. #' to \code{\link{runGdal}} and \code{\link{runMrt}}, defaults to \code{"asIn"}.
  15. #' @param outProj Target reference system passed to \code{\link{runGdal}} and
  16. #' \code{\link{runMrt}}. \code{\link{runGdal}} requires a valid
  17. #' \code{\link{CRS}}. As for \code{\link{runMrt}}, please consult the MRT manual.
  18. #' Since the two pocessing methods do not have common methods, it is suggested
  19. #' to stick with the default settings (see Details).
  20. #' @param resamplingType Defaults to \code{"NN"} (Nearest Neightbour). MRT and
  21. #' GDAL both support \code{c('NN', 'CC', 'BIL')}. In addition, GDAL supports
  22. #' \code{cubicspline} and \code{lanczos} and, from \code{GDAL >= 1.10.0} onwards,
  23. #' also \code{mode} and \code{average}.
  24. #' @param dataFormat \code{character}, defaults to \code{"GTiff"}. One of
  25. #' \code{getOption("MODIS_gdalOutDriver")} (column 'name').
  26. #' @param gdalPath \code{character}. Path to gdal bin directory and more
  27. #' relevant for Windows users. Use \code{MODIS:::checkTools("GDAL")} to try to
  28. #' detect it automatically.
  29. #' @param MODISserverOrder \code{character}. Possible options are \code{"LAADS"}
  30. #' (default) and \code{"LPDAAC"} (see 'dlmethod' and 'Details'). If only one
  31. #' server is selected, all efforts to download data from the second server
  32. #' available are inhibited.
  33. #' @param dlmethod \code{character}, defaults to \code{auto}. See 'method' in
  34. #' \code{\link{download.file}}. On Unix (also Mac?), it is suggested to use
  35. #' \code{"wget"} or, if installed, \code{"aria2"}. In order to download MODIS
  36. #' files from LPDAAC, please note that either wget (default) or curl must be
  37. #' installed and made available through the PATH environmental variable.
  38. #' @param stubbornness \code{numeric}. The number of retries after the target
  39. #' server has refused a connection. Higher values increase the chance of getting
  40. #' the file, but also lead to hanging functions if the server is down.
  41. #' @param wait \code{numeric} waiting time (in seconds) inserted after each
  42. #' internal online download call via \code{\link{download.file}} or
  43. #' \code{\link{getURL}}. Reduces the chance of FTP connection errors that
  44. #' frequently occur after many requests.
  45. #' @param systemwide A \code{logical} determining whether changes made to
  46. #' \code{\link{MODISoptions}} are to be applied system or user-wide (default),
  47. #' see 'Details'.
  48. #' @param quiet \code{logical} passed eg to \code{\link{download.file}} which is
  49. #' called from inside \code{\link{getHdf}}.
  50. #' @param save \code{logical}. If \code{TRUE} (default), settings are permanent.
  51. #' @param checkTools \code{logical}, defaults to \code{TRUE}. Check if external
  52. #' tools (i.e., GDAL and MRT) are installed and reachable through R.
  53. #'
  54. #' @return
  55. #' An invisible \code{list} of \strong{MODIS} options. In addition, the most
  56. #' relevant of these options are printed to the console. Use
  57. #' \code{\link{capture.output}} to prevent this behavior.
  58. #'
  59. #' @details
  60. #' These settings are easy to change and take effect immediately! However,
  61. #' please mind that the \href{https://cran.r-project.org/web/packages/policies.html}{CRAN Repository Policy}
  62. #' does not permit automated write access to the user's file system exempt for
  63. #' \code{\link{tempdir}}. Therefore, changes made to \code{\link{MODISoptions}}
  64. #' remain temporally limited to the current \strong{\code{R}} session unless write
  65. #' access is explicitly granted by the user in interactive mode, in which case a
  66. #' permanent settings file is created in \code{file.path("~/.MODIS_Opts.R")}
  67. #' (user-wide) or \code{file.path(R.home(component = "etc"), '.MODIS_Opts.R')}
  68. #' (system-wide, write access provided).
  69. #'
  70. #' Due to similar reasons, 'localArcPath' and 'outDirPath' default to
  71. #' \strong{\code{R}}'s \code{\link{tempdir}} and should be changed immediately
  72. #' after loading the package in order to make downloaded files permanently
  73. #' available. You may also specify a shared network drive if you have a central
  74. #' MODIS data server.
  75. #'
  76. #' If you change default values, consider that your settings have to be valid
  77. #' for any MODIS product, layer and area!
  78. #'
  79. #' It is not recommended to use
  80. #' \itemize{
  81. #' \item{a coordinate reference system that is not applicable globally as
  82. #' default for 'outProj',}
  83. #' \item{or a fixed 'pixelSize' for different products,}
  84. #' \item{or a 'resamplingType' that is not \code{"NN"}.}
  85. #' }
  86. #'
  87. #' On Windows, you have to set 'gdalPath' to the location of GDAL executables
  88. #' (i.e., the '.../GDAL../bin' directory). On Unix-alikes, this should not be
  89. #' required unless you want to specify a non-default GDAL installation.
  90. #'
  91. #' On an unixoid OS, it is suggested to use \code{dlmethod = 'wget'} because it
  92. #' is a reliable tool and, after the change of the 'LP DAAC' datapool from FTP
  93. #' to HTTP (May 2013), \code{dlmethod = 'auto'} seems not to work properly. On
  94. #' Windows, on the other hand, \code{dlmethod = 'auto'} seems to work fine.
  95. #'
  96. #' Please note that in order to download MODIS files from LPDAAC, you are
  97. #' required to register for an Earthdata Login Profile
  98. #' (\url{https://urs.earthdata.nasa.gov/users/new}) and create a read-only
  99. #' .netrc file in your home directory containing the Earthdata server address as
  100. #' well as your login credentials. An automated solution for the creation of a
  101. #' workable .netrc file is provided through \code{\link{lpdaacLogin}}.
  102. #'
  103. #' @author
  104. #' Matteo Mattiuzzi, Steven Mosher and Florian Detsch
  105. #'
  106. #' @examples
  107. #' \dontrun{
  108. #' ## get options
  109. #' MODISoptions()
  110. #'
  111. #' ## set options
  112. #' lap = "/another/path/to/MODIS_ARC" # 'localArcPath'
  113. #' odp = file.path(lap, "PROCESSED") # 'outDirPath'
  114. #'
  115. #' MODISoptions(localArcPath = lap, outDirPath = odp)
  116. #' }
  117. #'
  118. #' @export MODISoptions
  119. #' @name MODISoptions
  120. MODISoptions <- function(localArcPath, outDirPath, pixelSize, outProj,
  121. resamplingType, dataFormat, gdalPath, MODISserverOrder,
  122. dlmethod, stubbornness, wait, quiet,
  123. systemwide = FALSE, save = TRUE, checkTools = TRUE)
  124. {
  125. # This function collects the package options from up to 3 files and creates
  126. # the .MODIS_Opts.R file (location depending on systemwide=T/F, see below):
  127. # 1. package installation directory (factory defaults);
  128. # 2. /R/etc/.MODIS_Opts.R for system wide settings (all users of a machine) and
  129. # 3. user home "~/.MODIS_Opts.R", for user specific settings.
  130. # settings are collected in direction 1-3 and each time overwritten if available
  131. # The final settings are written in to the user specific file 3.
  132. # options are not tested here! only generated!
  133. # container for all options
  134. opts <- new.env()
  135. ##################################
  136. # 1. factory defaults -----
  137. ofl = suppressWarnings(
  138. system.file("external", "MODIS_Opts.R", package = "MODIS")
  139. )
  140. if (ofl == "")
  141. ofl = file.path(getwd(), "inst/external/MODIS_Opts.R")
  142. eval(parse(ofl), envir = opts)
  143. # 2. system wide -----
  144. sysopts <- paste(R.home(component = "etc"), '.MODIS_Opts.R', sep = '/')
  145. so <- FALSE
  146. if (file.exists(sysopts)) {
  147. eval(parse(sysopts), envir = opts)
  148. so <- TRUE
  149. }
  150. # 3. user specific -----
  151. optfile <- file.path("~/.MODIS_Opts.R", fsep = "/")
  152. uo <- FALSE
  153. # system-wide
  154. if(systemwide) {
  155. if(!file.create(sysopts, showWarnings = FALSE))
  156. stop("You do not have sufficient permissions to create or change ",
  157. "'systemwide' MODIS options. Set 'systemwide = FALSE' for user-wide",
  158. " settings or start R as root/admin and re-run MODISoptions().\n")
  159. optfile <- sysopts
  160. whose <- 'systemwide'
  161. # user-wide
  162. } else {
  163. tmpopt = file.path(tempdir(), ".MODIS_Opts.R")
  164. if (any(file.exists(optfile), file.exists(tmpopt))) {
  165. eval(parse(ifelse(file.exists(optfile), optfile, tmpopt)), envir = opts)
  166. uo <- TRUE
  167. }
  168. whose <- 'user'
  169. }
  170. # if(!uo) {
  171. # if(!so & save) {
  172. # warning("No MODIS 'user' nor 'systemwide' settings file found. File is created for '",whose,"'-settings in: ",normalizePath(optfile,'/',mustWork=FALSE),sep="")
  173. # } else if (!save) {
  174. # warning("No MODIS 'user' nor 'systemwide' settings file found, using factory defaults. Use '?MODISoptions' to configure the 'MODIS' package and make settings permanent!")
  175. # }
  176. # }
  177. #################################
  178. opt <- as.list(opts)
  179. # localArcPath
  180. opt$localArcPath <- correctPath(opt$localArcPath)
  181. if(!missing(localArcPath)) {
  182. localArcPath <- correctPath(localArcPath)
  183. if (opt$localArcPath != localArcPath) {
  184. message("Setting 'localArcPath' to '"
  185. , normalizePath(localArcPath, "/", FALSE)
  186. , "'\nIf you already have downloaded some HDF files, "
  187. , "you can use '?orgStruc' to rearrange them.")
  188. }
  189. options(MODIS_localArcPathWarned=TRUE)
  190. opt$localArcPath <- localArcPath
  191. } else {
  192. if (length(list.dirs(opt$localArcPath,recursive=FALSE))==0)
  193. {
  194. if(!isTRUE(options()$MODIS_localArcPathWarned))
  195. {
  196. message("'localArcPath' does not exist and will be created in '"
  197. , normalizePath(opt$localArcPath, "/", FALSE)
  198. , "'. Consult '?MODISoptions' if you want to change it!")
  199. options(MODIS_localArcPathWarned=TRUE)
  200. }
  201. }
  202. }
  203. # outDirPath
  204. opt$outDirPath <- correctPath(opt$outDirPath)
  205. if(!missing(outDirPath))
  206. {
  207. outDirPath <- correctPath(outDirPath)
  208. if (length(list.dirs(opt$outDirPath,recursive=FALSE))==0)
  209. {
  210. message("'outDirPath' does not exist and will be created in '"
  211. , normalizePath(outDirPath, "/", FALSE), "'.")
  212. } else if (opt$outDirPath != outDirPath)
  213. {
  214. message("'outDirPath' has been changed from '"
  215. , normalizePath(opt$outDirPath, "/", FALSE)
  216. , "' to '", normalizePath(outDirPath, "/", FALSE), "'.")
  217. }
  218. options(MODIS_outDirPathWarned=TRUE)
  219. opt$outDirPath <- outDirPath
  220. } else
  221. {
  222. if (length(list.dirs(opt$outDirPath,recursive=FALSE))==0)
  223. {
  224. if(!isTRUE(options()$MODIS_outDirPathWarned))
  225. {
  226. message("'outDirPath' does not exist and will be created in '"
  227. , normalizePath(opt$outDirPath, "/", FALSE)
  228. , "'. Consult '?MODISoptions' if you want to change it!")
  229. options(MODIS_outDirPathWarned=TRUE)
  230. }
  231. }
  232. }
  233. opt$auxPath <- paste0(opt$outDirPath,".auxiliaries/")
  234. if(!missing(dlmethod))
  235. {
  236. dlmethod <- tolower(dlmethod)
  237. stopifnot(dlmethod %in% c("auto","internal","wget","curl","lynx","aria2"))
  238. opt$dlmethod <- dlmethod
  239. }
  240. if(!missing(stubbornness))
  241. {
  242. opt$stubbornness <- stubbornness
  243. }
  244. if (!missing(wait)) opt$wait <- wait
  245. if (!missing(quiet)) opt$quiet <- quiet
  246. if(!missing(resamplingType))
  247. {
  248. stopifnot(tolower(resamplingType) %in% c('nn', 'cc', 'bil','near', 'bilinear', 'cubic','cubicspline','lanczos', 'average', 'mode'))
  249. opt$resamplingType <- resamplingType
  250. }
  251. if(!missing(outProj))
  252. {
  253. opt$outProj <- outProj
  254. }
  255. if(!missing(pixelSize))
  256. {
  257. opt$pixelSize <- pixelSize
  258. }
  259. if (!missing(gdalPath))
  260. {
  261. opt$gdalPath <- correctPath(gdalPath)
  262. if(length(grep(dir(opt$gdalPath),pattern="gdalinfo"))==0)
  263. {
  264. stop(paste0("The 'gdalPath' you have provided '",normalizePath(opt$gdalPath,"/",FALSE) ,"' does not contain any gdal utilities, make sure to address the folder with GDAL executables (ie: gdalinfo)!"))
  265. }
  266. }
  267. opt$gdalPath <- correctPath(opt$gdalPath)
  268. options(MODIS_gdalPath=opt$gdalPath) # needs to be exportet now as it is required by checkTools a few lines bellow (uses combineOptions())! Maybe not the best solution!
  269. if(is.null(opt$MODISserverOrder))
  270. {
  271. opt$MODISserverOrder <- c("LAADS", "LPDAAC")
  272. }
  273. if (!missing(MODISserverOrder))
  274. {
  275. MODISserverOrder <- toupper(MODISserverOrder)
  276. if(length(MODISserverOrder)==1)
  277. {
  278. if("LPDAAC" %in% MODISserverOrder | "LAADS" %in% MODISserverOrder)
  279. {
  280. opt$MODISserverOrder <- MODISserverOrder
  281. }
  282. } else if(length(MODISserverOrder)==2)
  283. {
  284. if("LPDAAC" %in% MODISserverOrder & "LAADS" %in% MODISserverOrder)
  285. {
  286. opt$MODISserverOrder <- MODISserverOrder
  287. }
  288. } else
  289. {
  290. stop("Provide valid 'MODISserverOrder' see '?MODISoptions'")
  291. }
  292. }
  293. # checks if the pointed GDAL exists and supports 'HDF4Image' driver.
  294. if(checkTools)
  295. {
  296. # GDAL
  297. isOk <- checkGdalDriver(path=opt$gdalPath)
  298. if (isOk)
  299. {
  300. opt$gdalOk <- TRUE
  301. gdalVersion <- checkTools(tool="GDAL",quiet=TRUE, opts = opt)$GDAL$version
  302. } else
  303. {
  304. opt$gdalOk <- FALSE
  305. gdalVersion <- "Not available. Use 'MODIS:::checkTools('GDAL')' for more information!"
  306. }
  307. # MRT
  308. mrt <- checkTools(tool="MRT",quiet=TRUE, opts = opt)$MRT
  309. if(mrt$MRT)
  310. {
  311. opt$mrtOk <- TRUE
  312. mrtVersion <- mrt$version
  313. } else
  314. {
  315. opt$mrtOk <- FALSE
  316. mrtVersion <- "Not available. Use 'MODIS:::checkTools('MRT')' for more information!"
  317. }
  318. } else
  319. {
  320. if(!isTRUE(opt$gdalOk)) # if TRUE, MODIS has all info it requires about GDAL
  321. {
  322. opt$gdalOk <- FALSE
  323. }
  324. if(!isTRUE(opt$mrtOk)) # if TRUE, MODIS has all info it requires about MRT
  325. {
  326. opt$mrtOk <- FALSE
  327. }
  328. gdalVersion <- "Not checked, run 'MODISoptions(checkPackages=TRUE)'"
  329. mrtVersion <- "Not checked, run 'MODISoptions(checkPackages=TRUE)'"
  330. }
  331. if(!missing(dataFormat))
  332. {
  333. opt$dataFormat <- dataFormat
  334. }
  335. if(is.null(opt$dataFormat))
  336. {
  337. opt$dataFormat <- 'GTiff'
  338. }
  339. if(checkTools & opt$gdalOk)
  340. {
  341. opt$gdalOutDriver <- gdalWriteDriver(renew = FALSE, quiet = FALSE, gdalPath=opt$gdalPath,outDirPath=opt$outDirPath)
  342. }
  343. if (save) {
  344. # let user decide whether to make settings permanent
  345. answer = if (!file.exists(optfile)) {
  346. readline(paste0("File '", optfile, "' does not exist. Create it now to "
  347. , "make settings permanent? [y/n]: "))
  348. } else "y"
  349. filename = file(ifelse(tolower(answer) %in% c("y", "yes"), optfile, tmpopt)
  350. , open = "wt")
  351. write(paste0('# This file contains ', whose,' default values for the R package \'MODIS\'.'), filename)
  352. write('# version 1.1.1', filename)
  353. write('# consult \'?MODISoptions\' for details and explanations', filename)
  354. write(' ', filename)
  355. write('#########################', filename)
  356. write('# 1.) Path and archive structure defaults.', filename)
  357. write('# consult \'?MODISoptions\' for more details', filename)
  358. write('# USE SINGLE FORWARD SLASH "/" (also on WINDOWS)', filename)
  359. write('# If path does not exist it is created!', filename)
  360. write('# Work also with network share!', filename)
  361. write(' ', filename)
  362. write('# All HDF-data will be (properly) stored in this directory.',filename)
  363. write(paste0('localArcPath <- \'',normalizePath(opt$localArcPath,"/",FALSE),'\''), filename)
  364. write(' ', filename)
  365. write('# Default output location for MODIS package processing results.',filename)
  366. write(paste0('outDirPath <- \'',normalizePath(opt$outDirPath,"/",FALSE), '\''),filename)
  367. write(' ', filename)
  368. write('#########################', filename)
  369. write('# 2.) download defaults:', filename)
  370. write('# consult \'?MODISoptions\' for more details', filename)
  371. write(' ', filename)
  372. if(length(opt$MODISserverOrder)==2)
  373. {
  374. write(paste0('MODISserverOrder <- c(\'',paste(opt$MODISserverOrder,collapse="', '"),'\')' ), filename)
  375. } else
  376. {
  377. write(paste0('MODISserverOrder <- \'',opt$MODISserverOrder,'\'' ), filename)
  378. }
  379. write(paste0('dlmethod <- \'',opt$dlmethod,'\'' ), filename)
  380. write(paste0('stubbornness <- \'',opt$stubbornness,'\''), filename)
  381. write(paste0('wait <- ',opt$wait), filename)
  382. write(paste0('quiet <- ',opt$quiet), filename)
  383. write(' ', filename)
  384. write('#########################', filename)
  385. write('# 3.) Processing defaults:', filename)
  386. write('# It is highly recommended to not modify here, at least not \'resamplingType\' as there are several layers that require NN (i.e. \'VI_Quality\', \'Day of the year\',...)!', filename)
  387. write('# consult \'?MODISoptions\' for more details', filename)
  388. write(' ', filename)
  389. write(paste0('resamplingType <- \'',opt$resamplingType,'\''), filename)
  390. write(paste0('outProj <- \'',opt$outProj,'\''),filename)
  391. write(paste0('pixelSize <- \'',opt$pixelSize,'\''),filename)
  392. write(paste0('dataFormat <- \'',opt$dataFormat,'\''),filename)
  393. write(' ', filename)
  394. write('#########################', filename)
  395. write('# 4.) Set path to GDAL _bin_ directory', filename)
  396. write('# More related to Windows, but also to other OS in case of a non standard location of GDAL', filename)
  397. write('# ON WINDOWS install \'OSGeo4W\' (recommanded) or \'FWTools\'', filename)
  398. write('# consult \'?MODISoptions\' for more details', filename)
  399. write('# Run: \'MODIS:::checkTools()\' to try to autodetect location.', filename)
  400. write('# Example (USE SINGLE FORWARD SLASH \'/\'!):', filename)
  401. write('# gdalPath <- \'C:/OSGeo4W/bin/\'', filename)
  402. write(' ', filename)
  403. if (!is.null(opt$gdalPath))
  404. {
  405. write(paste0("gdalPath <- '",normalizePath(opt$gdalPath,"/",FALSE),"'"), filename)
  406. }
  407. write(' ', filename)
  408. write('#########################', filename)
  409. write('#########################', filename)
  410. write('# 5.) Package internal information, do ot change manually', filename)
  411. write(' ', filename)
  412. write(paste0('gdalOk <- ', opt$gdalOk), filename)
  413. write(paste0('mrtOk <- ', opt$mrtOk), filename)
  414. write(' ', filename)
  415. close(filename)
  416. }
  417. cat('\nSTORAGE:\n')
  418. cat('_______________\n')
  419. cat('localArcPath :', normalizePath(opt$localArcPath,"/",FALSE), '\n' )
  420. cat('outDirPath :', normalizePath(opt$outDirPath,"/",FALSE), '\n\n\n')
  421. cat('DOWNLOAD:\n')
  422. cat('_______________\n')
  423. cat('MODISserverOrder :', paste(opt$MODISserverOrder,collapse=", "),'\n')
  424. cat('dlmethod :', opt$dlmethod,'\n')
  425. cat('stubbornness :', opt$stubbornness,'\n')
  426. cat('wait :', opt$wait, "\n")
  427. cat('quiet :', opt$quiet, "\n\n\n")
  428. cat('PROCESSING:\n')
  429. cat('_______________\n')
  430. cat('GDAL :', gdalVersion, '\n')
  431. cat('MRT :', mrtVersion, '\n')
  432. cat('pixelSize :', opt$pixelSize, '\n')
  433. cat('outProj :', opt$outProj, '\n')
  434. cat('resamplingType :', opt$resamplingType, '\n')
  435. cat('dataFormat :', opt$dataFormat, '\n\n\n')
  436. # remove ftpstring* from opt (old "~/.MODIS_Opts.R" style)
  437. oldftp <- grep(names(opt),pattern="^ftpstring*")
  438. if(length(oldftp)>1)
  439. {
  440. opt <- opt[-oldftp]
  441. }
  442. # set the options
  443. for (i in seq_along(opt))
  444. {
  445. if (is.character(opt[[i]]))
  446. {
  447. # if(length(opt[[i]])==1)
  448. # {
  449. # eval(parse(text=paste0("options(MODIS_",names(opt[i]),"='",opt[[i]],"')")))
  450. # } else
  451. # {
  452. eval(parse(text=paste0("options(MODIS_",names(opt[i]),"= c('",paste0(opt[[i]],collapse="', '"),"'))")))
  453. # }
  454. } else if (is.data.frame(opt[[i]]) | is.matrix(opt[[i]]))
  455. {
  456. eval(parse(text=paste0("options(MODIS_",names(opt[i]),"=opt$",names(opt[i]),")")))
  457. } else
  458. {
  459. eval(parse(text=paste0("options(MODIS_",names(opt[i]),"=",opt[[i]],")")))
  460. }
  461. }
  462. # this is fixed
  463. options(MODIS_arcStructure='/SENSOR/PRODUCT.CCC/DATE')
  464. return(invisible(opt))
  465. }