Skip to contents

Internal function used to perform the required spatial processing on MODIS original hdf layers (reprojection, resizing, resampling, mosaicing, computation of scaling factors). The function is based on the use of gdal routines.

Usage

MODIStsp_process_bands(
  out_folder_mod,
  modislist,
  outproj_str,
  mod_proj_str,
  sens_sel,
  band,
  bandname,
  date_name,
  datatype,
  nodata_in,
  nodata_out,
  full_ext,
  bbox,
  scale_val,
  scale_factor,
  offset,
  out_format,
  outrep_file,
  compress,
  out_res_sel,
  out_res,
  resampling,
  nodata_change,
  gui,
  verbose,
  parallel
)

Arguments

out_folder_mod

character Output folder for original HDF storage. If "$tempdir" (default), a temporary directory is used.

modislist

character array List of MODIS images to be downloaded for the selected date (as returned from get_mod_filenames). Can be a single image, or a list of images in case different tiles are needed!

outproj_str

character EPSG or WKT of output projection.

mod_proj_str

character EPSG or WKT of MODIS projection.

sens_sel

character ["terra" | "aqua"] Selected sensor.

band

numeric band number corresponding to the HDF layer to be processed

bandname

character Name of the HDF layer to be processed.

date_name

character Date of acquisition of the images to be downloaded.

datatype

character Datatype to the HDF layer to be processed.

nodata_in

numeric Original nodata value to the HDF layer to be processed.

nodata_out

numeric Output nodata value to the HDF layer to be processed.

full_ext

logical If TRUE, process full tiles, if FALSE, process bbox

bbox

numeric(4) Output bounding box (xmin, ymin, xmax, ymax) in out_proj coordinate system. Ignored if spatmeth == "tiles", Default: NULL

scale_val

logical If TRUE, scale and offset are applied to original MODIS layers, and Spectral Indexes are saved as floating point. If FALSE, no rescaling is done and Spectral Indexes are saved as integer, with a 10000 scaling factor.

scale_factor

numeric Scale factor to be applied to the HDF layer to be processed (Ignored if scale_val == FALSE).

offset

numeric Offset to be applied to the HDF layer to be processed (Ignored if scale_val == FALSE).

out_format

character ["ENVI" | "GTiff"] Desired output format.

outrep_file

character Full path of the file where results of the processing are to be stored (created in MODIStsp_process)

compress

character ["None" | "PACKBITS" | "LZW" | "DEFLATE"] Compression method for GTiff outputs (Ignored if out_format == ENVI)

out_res_sel

character ["Native", "User Defined]. If "Native", the outputs keep the original resolution of MODIS HDF images. Otherwise, the value set in "out_res" is used.

out_res

float Output resolution (in output projection measurement unit). Ignored if out_res_sel == "Native".

resampling

character ["near" | "bilinear" | "cubic" | "cubicspline", |lanczos"|, "average"|, "mode", |"max"|, |"min"|, |"q1"|, |"q3"|, |"sum"|] Resampling method to be used by gdalwarp.

nodata_change

logical if TRUE, NoData values are set to the max value of the datatype of the layer on the MODIStsp output rasters. NOTE: If multiple nodata values are reported for a layer, all are reset to the new value.

gui

logical if TRUE: the GUI is opened before processing. If FALSE: processing parameters are retrieved from the provided opts_file argument), Default: TRUE

verbose

logical If FALSE, suppress processing messages, Default: TRUE

parallel

logical If TRUE, the function is run using parallel processing, to speed-up the computation for large rasters (with a maximum of 8 cores). The number of cores is automatically determined; specifying it is also possible (e.g. parallel = 4). In this case, more than 8 cores can be specified. If FALSE (default), single core processing is used.

Value

The function is called for its side effects

Author

Lorenzo Busetto, phD (2014-2017)

Luigi Ranghetti, phD (2015)