Format grid properties for GDAL command line options (-ts for target size, -te for target extent).

ts_te(dimension, extent)

te(extent)

ts(dimension)

Arguments

dimension

integer vector of ncol, nrow (target size)

extent

numeric vector of xmin, xmax, ymin, ymax (target extent)

Value

A character string formatted for GDAL command line:

  • ts_te(): combined -ts and -te arguments

  • ts(): -ts ncol nrow string

  • te(): -te xmin ymin xmax ymax string (note: reordered for GDAL)

Details

These functions generate the string arguments used by GDAL utilities like gdalwarp and gdal_translate. The ts() function is named after the GDAL -ts flag and masks stats::ts(); use ts_te() or qualify with stats::ts() if you need the time series function.

Note

ts() masks stats::ts(). This is intentional for concise GDAL command building, but be aware of the conflict if you use time series in the same session.

See also

vcrop() for computing aligned extents

Examples

ts_te(c(10, 100), 1:4)
#> [1] "-ts 10 100 -te 1 3 2 4"

ts(c(10, 100))
#> [1] "-ts 10 100"

te(1:4)
#> [1] "-te 1 3 2 4"

## use in a GDAL command (not run)
if (FALSE) { # \dontrun{
cmd <- sprintf("gdalwarp %s %s input.tif output.tif",
               ts(c(1000, 500)), te(c(-180, 180, -90, 90)))
} # }