dsn <- system.file("extdata/sst.tif", package = "vapour")
## 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
if (interactive()) {
cutline <- tempfile(fileext = ".csv")
wkt <- "POLYGON ((142 -41, 149 -41, 146 -58, 142 -41))"
write.csv(data.frame(id = 1, WKT = wkt), cutline, row.names = FALSE)
X1c <- gdal_raster_data(dsn, target_res = .5,
options = c("-cutline",cutline, "-crop_to_cutline"))
file.remove(cutline)
}
## warp whole grid to given res
X2 <- gdal_raster_data(dsn, target_res = 25000, target_crs = "EPSG:32755")
## 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")
X4 <- gdal_raster_dsn(dsn, out_dsn = tempfile(fileext = ".tif"))
Run the code above in your browser using DataLab