MODIStsp_process: MODIStsp main processing function

Description Usage Arguments Details Value Note Author(s)

View source: R/MODIStsp_process.R

Description

Main processing function of MODIStsp. Takes as input processing parameters specified by the user using MODIStsp_GUI and saved in MODIStsp_Previous.json (Interactive mode), or a user specified JSON file (non-interactive mode) and performs all required processing.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
MODIStsp_process(sel_prod, start_date, end_date, out_folder,
  out_folder_mod, reprocess = "Yes", delete_hdf = "No", sensor,
  download_server, user, password, https, start_x, start_y, end_x, end_y,
  full_ext, bbox, out_format, compress, out_res_sel, out_res, native_res,
  tiled, mod_proj_str, outproj_str, nodata_in, nodata_out, nodata_change,
  scale_val, scale_factor, offset, datatype, bandsel, bandnames,
  indexes_bandsel, indexes_bandnames, indexes_formula, indexes_nodata_out,
  quality_bandnames, quality_bandsel, quality_bitN, quality_source,
  quality_nodata_in, quality_nodata_out, file_prefixes, main_out_folder,
  resampling, ts_format, use_aria = TRUE, download_range = "full",
  gui = TRUE, n_retries, verbose)

Arguments

sel_prod

character Name of selected MODIS product.

start_date

character Start date for images download and preprocessing (yyyy.mm.dd).

end_date

character End date for images download and preprocessing (yyyy.mm.dd).

out_folder

character Main output folder.

out_folder_mod

character Output folder for original HDF storage.

reprocess

character ["Yes" | "No"] If Yes, reprocess data for already existing dates.

delete_hdf

character ["Yes" | "No"] If Yes, delete original HDF after completion.

sensor

character ["Terra"| "Aqua" | "Both"] MODIS platform to be considered. (Ignored for MCD* products).

download_server

character ["http" | "offline"] service to be used for download.

user

character Username for NASA http server. (urs.earthdata.nasa.gov/home).

password

character Password for NASA http server (urs.earthdata.nasa.gov/home).

https

list http addresses for download of HDF of selected product.

start_x

integer [0-35] Start horizontal tile.

start_y

integer [0-17] Start vertical tile.

end_x

integer [0-35] End horizontal tile.

end_y

integer [0-17] End vertical tile.

full_ext

characrter ["FullTiles" | "Resized"] If "Full_Ext", process the entire extent of the selected tiles. Otherwise, crop the output to output bbox.

bbox

numeric(4) Output bounding box (xmin, ymin, xmax, ymax) in out_proj coordinate system.

out_format

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

compress

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

out_res_sel

character ["Native" | "Resampled"] Indicates if the native resolution of the product or a user supplied one is to be used.

out_res

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

native_res

float Native resolution of MODIS product to be processed.

tiled

integer [0 | 1] 1 = tiled product; 0 = non-tiled product (resolution 0.05 deg - latlong projection).

mod_proj_str

character proj4 string of MODIS product native projection.

outproj_str

character proj4 string of selected output projection.

nodata_in

numeric array Original NoData values of original layers of the selected MODIS product.

nodata_out

numeric array Target NoData values of MODIS original layers (Ignored if nodata_change == FALSE).

nodata_change

character ["Yes" | "No"] if Yes, NoData are set to nodata_out in output rasters.

scale_val

character ["Yes" | "No"] If == "Yes", scale and offset are applied to original MODIS layers, and Spectral Indexes are saved as floating point. If == "No", no rescaling is done and Spectral Indexes are saved as integer, with a 10000 scaling factor.

scale_factor

numeric array of length equal to the number of original layers of the selected product, containing scale factors to be applied to each original layer to convert it to "correct" measure units.

offset

numeric array of length equal to the number of original layers of the selected product, containing offsets to be applied to each original layer to convert it to "correct" measure units.

datatype

character array datatypes of original MODIS bands (e.g., "INT2S").

bandsel

integer 0/1 array of length equal to number of original layers of the selected product set to 1 for bands to be processed.

bandnames

character array Abbreviated Names of original layers of the selected product (used to build output file names).

indexes_bandsel

integer 0/1 array array of length equal to the number of Spectral Indexes available for the product (standard + user-provided), set to 1 for indexes to be processed.

indexes_bandnames

character array Abbreviated Names of SIs available for the selected product (used to build output file names of SIs).

indexes_formula

character array formulas of SIs available for the selected product (standard and custom).

indexes_nodata_out

numeric array NoData values to be used for SIs

quality_bandnames

character array Abbreviated Names of Quality Indicators available for the selected product (used to build output file names of QIs).

quality_bandsel

integer 0|1 array array of length equal to number of available QIs, set to 1 for indexes to be processed.

quality_bitN

character array with length equal to the number QIs available for the selected product. Each entry contains the position of the bits corresponding to a QI (e.g., 0-1) in its "source" MODIS layer.

quality_source

character array which connects each QI to its "source" original MODIS layer (multiple QIs share the same "source", since they are derived from different bits of the bit-encoded layer).

quality_nodata_in

integer Always set to 255.

quality_nodata_out

integer Always set to 255.

file_prefixes

character output file prefix of selected product (e.g., MOD13Q1). Used to build output filenames.

main_out_folder

character Main folder for storage of MODIStsp time series.

resampling

character ["near" | "bilinear" | "cubic" | "lanczos" | "mode"] Resampling method to be used by gdalwarp.

ts_format

character ["None" | "ENVI Meta Files" | "GDAL vrt files" | "ENVI and GDAL"] Selected virtual time series format.

use_aria

logical If TRUE, aria2c is used to accelerate download (if available !).

download_range

character ["full" | "seasonal"] If "full", all the available images between the starting and the ending dates are downloaded; If "seasonal", only the images included in the season are downloaded (e.g: if the starting date is 2005-12-01 and the ending is 2010-02-31, only the images of December, January and February from 2005 to 2010 - excluding 2005-01, 2005-02 and 2010-12 - are downloaded).

gui

logical Indicates if processing was called starting from an interactive environment or not. If FALSE, processing messages are sent to a log file instead than to the console, and gWidgets messages are suppressed

n_retries

numeric maximum number of retries on download functions. In case any download function fails more than n_retries times consecutively, MODIStsp_process will abort, Default: 20

verbose

logical If FALSE, suppress processing messages, Default: TRUE

Details

After retrieving the input processing options, the function

  1. Accesses NASA http archive to determine the list of files to be downloaded/processed (or, in case of offline processing, get the list of already available hdf files present in out_mod_folder);

  2. Performs all required processing steps on each date (download, reprojection, resize, mosaicing, Spectral Indexes and Quality indicators computation);

  3. Creates virtual files of the processed time series.

Reprojection and resize is dealt with by accessing gdal routines through the gdalUtils package. Extraction of bitfields from Quality layers is done though bitwise computation Checks are done in order to not re-download already existing HDF images, and not reprocess already processed dates (if the user did not specify that)

Value

The function is called for its side effects.

Note

Thanks Tomislav Hengl and Babak Naimi, whose scripts made the starting point for development of this function (ModisDownload; Download_and_resampling_of_MODIS_images)

License: GPL 3.0

Author(s)

Lorenzo Busetto, phD (2014-2017) [email protected]

Luigi Ranghetti, phD (2015) [email protected]


MODIStsp documentation built on Dec. 4, 2018, 1:04 a.m.