Learn R Programming

MODIS (version 1.2.11)

runGdal: Process MODIS HDF with GDAL

Description

Downloads MODIS grid files from archive (HTTP or local) and processes them.

Usage

runGdal(
  product,
  collection = NULL,
  begin = NULL,
  end = NULL,
  extent,
  tileH,
  tileV,
  SDSstring = NULL,
  job = NULL,
  checkIntegrity = TRUE,
  forceDownload = TRUE,
  overwrite = FALSE,
  maskValue = NULL,
  ...
)

Value

A list of the same length as 'product'. Each product slot either holds a sub-list of processed dates which, for each time step, includes the corresponding output files as character objects or, if no files could be found for the specified time period, a single NA.

Arguments

product

character, see getProduct().

collection

character or integer, see getCollection().

begin, end

Date or character. Begin and end date of MODIS time series, see transDate().

extent

Extent information, defaults to 'global'. See getTile().

tileH, tileV

numeric or character. Horizontal and vertical tile number, see getTile().

SDSstring

character, see getSds().

job

character. Name of the current job for the creation of the output folder. If not specified, it is created in 'PRODUCT.COLLECTION_DATETIME'.

checkIntegrity, forceDownload

logical, see getHdf().

overwrite

logical, defaults to FALSE. Determines whether or not to overwrite existing SDS output files.

maskValue

If NULL (default), i.e. not explicitly set, the per-band NoData Value is taken into account. If not NULL, a vector of masking values with each value corresponding to a single band in 'SDSstring'. This can include "None" to ignore intrinsic no-data settings on the source data set. See also https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-srcnodata for details.

...

Additional arguments passed to MODISoptions(), e.g. 'wait'. Permanent settings for these arguments are temporarily overridden.

Author

Matteo Mattiuzzi, Florian Detsch

Details

  • outProj, pixelSize, resamplingType, dataFormat, localArcPath, outDirPath: See MODISoptions().

  • blockSize: integer. If NULL (default), the stripe size is set by GDAL. Basically it is the -co BLOCKYSIZE= parameter. See https://gdal.org/frmt_gtiff.html.

  • compression logical. If TRUE (default), compress data with the lossless LZW compression with predictor=2. See https://gdal.org/frmt_gtiff.html.

runGdal() uses numerous MODIS functions under the hood, see the linked functions in Arguments for details and inputs.

If 'extent' is a Raster* object, the output has exactly the same extent, pixel size, and projection. If 'extent' is a sp or sf object, the output has exactly the same extent and projection except for point geometries with length 1 (i.e. a single point) where only the projection is inherited. If 'tileH' and 'tileV' are used (instead of 'extent') to define the area of interest, and 'outProj' and 'pixelSize' are "asIn", the result is only converted from multi-layer HDF to 'dataFormat', default "GTiff".

See Also

getHdf(), runMrt().

Examples

Run this code
if (FALSE) {
# LST in Austria
runGdal( product="MOD11A1", extent="austria", begin="2010001", end="2010005", SDSstring="101")

# LST with interactive tile selection
runGdal( product="MOD11A1", begin="2010001", end="2010005", SDSstring="101")

### outProj examples
# LST of Austria warped to UTM 34N (the three different possibilites to specify "outProj")
# to find am EPSG or prj4 you may use: prj <- make_EPSG() See  
runGdal( job="LSTaustria", product="MOD11A1", extent="Austria", begin="2010001", end="2010005",
         SDSstring="101", outProj="EPSG:32634")

runGdal( job="LSTaustria", product="MOD11A1", extent="Austria", begin="2010001", end="2010005",
         SDSstring="101", outProj=32634)

runGdal( job="LSTaustria", product="MOD11A1", extent="Austria", begin="2010001", end="2010005",
         SDSstring="101", outProj="+proj=utm +zone=34 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

### resamplingType examples
runGdal( job="LSTaustria", product="MOD11A1", extent="Austria", begin="2010001", end="2010005",
         SDSstring="1", resamplingType="lanczos", outProj="32634", pixelSize=100)

### processing entire tiles and keeping Sinusoidal projection
# This corresponds to a format conversion (eos-hdf04 to Geotiff) and 
# layer extraction (multi-layer to single layer)
runGdal( job="LSTaustria", product="MOD11A1", tileH=18:19,tileV=4, begin="2010001", end="2010005",
         SDSstring="1", outProj="asIn")

}

Run the code above in your browser using DataLab