Skip to content

4.9 tile.R

Mateusz Żółtak edited this page Oct 16, 2019 · 4 revisions

Retiles and reprojects rasters into the target grid.

Can work with data from both rawDir and periodsDir (see [configuration and storage](2-Configuration and storage)).

Command line arguments

A standard set of configFilePath, regionName, startDate and endDate.

Data input/output

Reads data from both rawDir and/or periodsDir and stores results into the tilesDir.

Output files date/period and band name simply follow input files ones.

Performance

This step is pretty CPU intensive, especially if more advances resampling methods are used.

Configuration

  • tileSkipExisting should already existing output tiles be skipped (TRUE) or reprocessed anyway (FALSE).
  • gridFile path to the file storing the target tiling grid. It must be in a format supported by the sf::read_sf R function (e.g. shapefile, geojson, kml). Tiles must be features and every tile must have a distinct TILE property value. The projection of this file determines the output data projection.
  • tileRawBands vector of bands from the rawDir to be processed, e.g. c('NDVI', 'B03').
  • tilePeriodBands a named list describing data from the periodsDir to be processed.
    • Name of every list element defines a period. Period definition consists of a number and a period type name (day, month or year), e.g. 1 year or 10 days. Period type name can be also provided in plural, e.g. 2 months, 1 years, 10 days.
    • Every list element value is a vector of band names to be processed for a given period kind, e.g. c('NDVIq05', 'NDVIq50', 'NDVIq98').
  • tileResamplingMethod resampling method to be used for reprojection - see the gdalwarp documentation.
  • tileGdalOpts command line options to be passed to the gdalwarp, e.g. ones specyfying output files compression. A good default should be --config GDAL_CACHEMAX 1024 -co "COMPRESS=DEFLATE" -co "TILED=YES" -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512"

For example a configuration retiling:

  • bands TCI and B03 from the rawDir,
  • monthly bands NDVI, and DoyMaxNDVI,
  • yearly bands NDVI2q05, NDVI2q50 and NDVI2q98

can look as follows:

tileSkipExisting = TRUE
tileRawBands = c('TCI', 'B03')
tilePeriodBands = list(
  '1 month' = c('NDVI', 'DoyMaxNDVI'),
  '1 year' = c('NDVI2q05', 'NDVI2q50', 'NDVI2q98')
)
tileResamplingMethod = 'near'
tileGdalOpts = '--config GDAL_CACHEMAX 1024 -co "COMPRESS=DEFLATE" -co "TILED=YES" -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512"'
Clone this wiki locally