Constructs the command-line arguments for GDAL's gdalwarp
utility, allowing for flexible reprojection and
resampling of raster data. The function can return either a vector of arguments for programmatic use or a complete
command string for manual execution when interactive = TRUE
.
Arguments
- path_in
character A vector of file paths to input rasters. Must be valid file paths.
- path_out
character A single file path for the output raster. The directory must exist.
- s_srs
character or NULL Optional. The source spatial reference system in any GDAL-supported format (e.g., EPSG codes, PROJ strings). Defaults to
NULL
, meaning it will be inferred from the input raster.- t_srs
character The target spatial reference system in any GDAL-supported format. Defaults to
"EPSG:3005"
.- resampling
character The resampling method. One of
"nearest"
,"bilinear"
,"cubic"
,"cubicspline"
,"lanczos"
,"average"
,"mode"
. Defaults to"bilinear"
.- target_resolution
numeric A numeric vector of length 2 specifying the output pixel resolution in meters for the x and y directions. Defaults to
c(0.15, 0.15)
(15cm x 15cm pixels).- overwrite
logical Whether to overwrite the output file if it exists. Defaults to
TRUE
.- interactive
logical Whether to return the full
gdalwarp
command as a string for manual use. Defaults toFALSE
.- params_default
character or NULL Optional. A character vector of default parameters to include in the
gdalwarp
command. Defaults toc("-multi", "-wo", "NUM_THREADS=ALL_CPUS")
.- params_add
character or NULL Optional. A character vector of additional parameters to include in the
gdalwarp
command.
Value
character A vector of arguments for programmatic use or a complete command string if interactive = TRUE
.
Details
The function constructs command-line arguments for gdalwarp
, enabling flexible raster reprojection, resampling, and
transformation. Note that gdalwarp
requires GDAL to be installed on your system. On macOS, you can install GDAL
using Homebrew by running brew install gdal
. For more details on gdalwarp
, visit: https://gdal.org/en/stable/programs/gdalwarp.html.
See also
Other spacehakr:
ngr_spk_ext_raster()
,
ngr_spk_odm()
,
ngr_spk_poly_to_points()
,
ngr_spk_res()
Other processx:
ngr_spk_odm()
Examples
if (FALSE) { # \dontrun{
# Generate arguments for programmatic use
args <- ngr_spk_gdalwarp(
path_in = c("input1.tif", "input2.tif"),
path_out = "output.tif",
s_srs = "EPSG:4326",
t_srs = "EPSG:3857",
target_resolution = c(0.1, 0.1)
)
# Generate a full command for manual use
cmd <- ngr_spk_gdalwarp(
path_in = c("input1.tif", "input2.tif"),
path_out = "output.tif",
s_srs = "EPSG:4326",
t_srs = "EPSG:3857",
target_resolution = c(0.1, 0.1),
interactive = TRUE
)
cat(cmd, "\n")
} # }