# Define product names
examplename <- system.file(
"extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif",
package = "sen2r"
)
# \donttest{
## gdalinfo
out0 <- gdalUtil("info", examplename, quiet = TRUE)
message(out0)
## gdal_translate
outname1 <- tempfile(fileext = ".tif")
gdalUtil(
"translate",
examplename, outname1,
options = c("-tr", "2", "2", "-r", "cubicspline", "-co", "COMPRESS=DEFLATE")
)
oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
image(stars::read_stars(examplename), rgb = c(11,8,4), useRaster = TRUE)
image(stars::read_stars(outname1), rgb = c(11,8,4), useRaster = TRUE)
## gdalwarp
outname2 <- tempfile(fileext = ".tif")
gdalUtil(
"warp",
examplename, outname2,
options = c("-t_srs", "EPSG:32633", "-co", "COMPRESS=DEFLATE")
)
oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
image(stars::read_stars(examplename), rgb = c(11,8,4), useRaster = TRUE)
image(stars::read_stars(outname2), rgb = c(11,8,4), useRaster = TRUE)
# }
if (FALSE) {
## gdal_calc
outname3 <- tempfile(fileext = ".tif")
ndvirefname <- system.file(
"extdata/out/S2A2A_20190723_022_Barbellino_NDVI_10.tif",
package = "sen2r"
)
gdalUtil(
"calc",
rep(examplename,2), outname3,
formula = "10000*(A.astype(float)-B)/(A+B)",
options = c("--A_band", "8", "--B_band", "4", "--type", "Int16")
)
oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
image(stars::read_stars(ndvirefname), useRaster = TRUE)
image(stars::read_stars(outname3), useRaster = TRUE)
}
Run the code above in your browser using DataLab