The warper is used to convert source/s to an output file or to data in memory.
gdal_raster_data(
dsn,
target_crs = NULL,
target_dim = NULL,
target_ext = NULL,
target_res = NULL,
resample = "near",
bands = 1L,
band_output_type = NULL,
options = character()
)
gdal_raster_dsn(
dsn,
target_crs = NULL,
target_dim = NULL,
target_ext = NULL,
target_res = NULL,
resample = "near",
bands = NULL,
band_output_type = NULL,
options = character(),
out_dsn = tempfile(fileext = ".tif")
)
gdal_raster_image(
dsn,
target_crs = NULL,
target_dim = NULL,
target_ext = NULL,
target_res = NULL,
resample = "near",
bands = NULL,
band_output_type = NULL,
options = character()
)
data sources, files, urls, db strings, vrt, etc
projection of the target grid
dimension of the target grid
extent of the target grid
resolution of the target grid
resampling algorithm used
band or bands to include, default is first band only (use NULL or a value less that one to obtain all bands)
specify the band type, see vapour_read_raster
general options passed to gdal warper
use with gdal_raster_dsn optionally set the output file name (or one will be generated)
pixel values in a list vector per band, or a list of file paths
Two functions 'gdal_raster_data' and 'gdal_raster_dsn' act like the gdalwarp command line tool, a convenience third function 'gdal_raster_image()' works especially for image data.
dsn <- system.file("extdata/sst.tif", package = "vapour")
par(mfrow = c(2, 2))
## do nothing, get native
X <- gdal_raster_data(dsn)
## set resolution (or dimension, extent, crs, or combination thereof - GDAL
## will report/resolve incompatible opts)
X1 <- gdal_raster_data(dsn, target_res = 1)
## add a cutline, and cut to it using gdal warp args
cutline <- system.file("extdata/cutline_sst.gpkg", package = "vapour")
X1c <- gdal_raster_data(dsn, target_res = .1, options = c("-cutline",cutline, "-crop_to_cutline" ))
#> Error: data source could not be processed with GDALWarp api
## warp whole grid to give res
X2 <- gdal_raster_data(dsn, target_res = 25000, target_crs = "EPSG:32755")
#> Warning: no source crs, target crs is ignored
## specify exactly (as per vapour originally)
X3 <- gdal_raster_data(dsn, target_ext = c(-1, 1, -1, 1) * 8e6,
target_dim = c(512, 678), target_crs = "+proj=stere +lon_0=147 +lat_0=-90")
#> Warning: no source crs, target crs is ignored
X4 <- gdal_raster_dsn(dsn, out_dsn = tempfile(fileext = ".tif"))