reads a raster file to a RasterLayer, RasterStack or RasterBrick, automatically checking if the input file is valid and is a single- or multi-band object.

read_rast(in_file, bands = NULL, verbose = TRUE)

Arguments

in_file

character filename to be read

bands

numeric array If the input is a multiband raster, band numbers to be read (e.g., bands = c(1,5,7) will read only the specified bands in a RasterStack)

verbose

logical If FALSE, processing messages are suppressed, Default: TRUE

Value

a RasterLayer, RasterStack or RasterBrick object

Details

DETAILS

Examples

# read a singleband file in_file <- system.file("extdata/REYE_test", "REYE_2016_185_gNDVI.tif", package = "sprawl.data") read_rast(in_file)
#> class : RasterLayer #> dimensions : 1763, 2081, 3668803 (nrow, ncol, ncell) #> resolution : 5, 5 (x, y) #> extent : 465485, 475890, 5004050, 5012865 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 #> data source : /home/lb/R/x86_64-pc-linux-gnu-library/3.5/sprawl.data/extdata/REYE_test/REYE_2016_185_gNDVI.tif #> names : REYE_2016_185_gNDVI #> values : -0.472001, 0.9999797 (min, max) #>
# read a multiband file in_file <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") read_rast(in_file)
#> class : RasterBrick #> dimensions : 447, 331, 147957, 46 (nrow, ncol, ncell, nlayers) #> resolution : 231.6564, 231.6564 (x, y) #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs #> data source : /home/lb/R/x86_64-pc-linux-gnu-library/3.5/sprawl.data/extdata/MODIS_test/EVIts_test.tif #> names : EVIts_test.1, EVIts_test.2, EVIts_test.3, EVIts_test.4, EVIts_test.5, EVIts_test.6, EVIts_test.7, EVIts_test.8, EVIts_test.9, EVIts_test.10, EVIts_test.11, EVIts_test.12, EVIts_test.13, EVIts_test.14, EVIts_test.15, ... #> min values : -621, -813, -834, -559, -323, -680, -557, -1886, -861, -884, -917, -550, -540, -1948, -1912, ... #> max values : 9971, 9167, 9307, 9988, 8706, 9767, 9740, 9939, 8452, 9358, 9983, 8504, 9858, 9976, 9980, ... #>
# read a multiband file selecting specific bands read_rast(in_file, bands = c(1,10))
#> class : RasterStack #> dimensions : 447, 331, 147957, 2 (nrow, ncol, ncell, nlayers) #> resolution : 231.6564, 231.6564 (x, y) #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs #> names : EVIts_test.1, EVIts_test.10 #> min values : -621, -884 #> max values : 9971, 9358 #>