Learn R Programming

MODIS (version 1.0.0)

MODISoptions: Set or Retrieve Permanent MODIS Package Options

Description

Set or retrieve persistant MODIS package options (per user or systemwide). Changes here will persist through sessions and updates.

Usage

MODISoptions(localArcPath, outDirPath, pixelSize, outProj, resamplingType,
  dataFormat, gdalPath, MODISserverOrder, dlmethod, stubbornness,
  systemwide = FALSE, quiet = FALSE, save = TRUE, checkTools = TRUE)

Arguments

localArcPath

character, defaults to "~/MODIS_ARC". Target folder for downloaded MODIS HDF files.

outDirPath

character, defaults to "~/MODIS_ARC/PROCESSED". Target folder for results of runGdal and runMrt.

pixelSize

Output pixel size (in target reference system units) passed to runGdal and runMrt, defaults to "asIn".

outProj

Target reference system passed to runGdal and runMrt. runGdal requires a valid CRS. As for runMrt, please consult the MRT manual. Since the two pocessing methods do not have common methods, it is suggested to stick with the default settings (see Details).

resamplingType

Defaults to "NN" (Nearest Neightbour). MRT and GDAL both support c('NN', 'CC', 'BIL'). In addition, GDAL supports cubicspline and lanczos and, from GDAL >= 1.10.0 onwards, also mode and average.

dataFormat

character, defaults to "GTiff". One of getOption("MODIS_gdalOutDriver") (column 'name').

gdalPath

character. Path to gdal bin directory and more relevant for Windows users. Use MODIS:::checkTools("GDAL") to try to detect it automatically.

MODISserverOrder

character. Possible options are "LAADS" (default) and "LPDAAC" (see 'dlmethod' and 'Details'). If only one server is selected, all efforts to download data from the second server available are inhibited.

dlmethod

character, defaults to auto. See 'method' in download.file. On Unix (also Mac?), it is suggested to use "wget" or, if installed, "aria2". In order to download MODIS files from LPDAAC, please note that either wget (default) or curl must be installed and made available through the PATH environmental variable.

stubbornness

numeric. The number of retries after the target server has refused a connection. Higher values increase the chance of getting the file, but also lead to hanging functions if the server is down.

systemwide

logical. If FALSE (default), 'user'-wide settings are saved to path.expand("~/.MODIS_Opts.R"). If TRUE, write settings to 'systemwide', presumed you have write access to paste(R.home(component="etc"), '/', '.MODIS_opts.R', sep='').

quiet

logical. If FALSE (default), options are printed to the console.

save

logical. If TRUE (default), settings are permanent.

checkTools

logical, defaults to TRUE. Check if external tools (i.e., GDAL and MRT) are installed and reachable through R.

Details

These settings are permanent, easy to change and take effect immediately!

If you change default values, consider that your settings have to be valid for any MODIS product, layer and area!

It is not recommended to use

  • a coordinate reference system that is not applicable globally as default for 'outProj',

  • or a fixed 'pixelSize' for different products,

  • or a 'resamplingType' that is not "NN".

'localArcPath' and 'outDirPath' should be changed, expecially on a Windows OS, as '~/MODIS_ARC/...' is normally on the 'C:/...' drive. You may also specify a shared network drive if you have a central MODIS data server.

On Windows, you have to set 'gdalPath' to the location of GDAL executables (i.e., the '.../GDAL../bin' directory). On Unix-alikes, this should not be required unless you want to specify a non-default GDAL installation.

On an unixoid OS, it is suggested to use dlmethod = 'wget' because it is a reliable tool and, after the change of the 'LP DAAC' datapool from FTP to HTTP (May 2013), dlmethod = 'auto' seems not to work properly. On Windows, on the other hand, dlmethod = 'auto' seems to work fine.

Please note that in order to download MODIS files from LPDAAC, you are required to register for an Earthdata Login Profile (https://urs.earthdata.nasa.gov/users/new) and create a read-only .netrc file in your home directory containing the Earthdata server address as well as your login credentials. An automated solution for the creation of a workable .netrc file is provided through lpdaacLogin.

Examples

Run this code

## get options
MODISoptions()

## set options
MODISoptions(localArcPath="/another/path/than/default")


Run the code above in your browser using DataLab