3.3 Importing raster data with terra
For this chapter, you will need the following R Packages:
## terra version 1.0.10
##
## Attaching package: 'arc2r'
## The following object is masked _by_ '.GlobalEnv':
##
## swissAlti3D
With the terra
package, data is imported using the function rast
.
library(terra)
<- terra::rast("sample_data/SWISSALTI3D_10_TIFF_CHLV95_LN02_2600_1196.tif") swissalti3d
Just like before, calling the object in our console will give us the class name and some meta information on the dataset.
swissalti3d
## class : SpatRaster
## dimensions : 100, 100, 1 (nrow, ncol, nlyr)
## resolution : 10, 10 (x, y)
## extent : 2600000, 2601000, 1196000, 1197000 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs
## source : SWISSALTI3D_10_TIFF_CHLV95_LN02_2600_1196.tif
## name : SWISSALTI3D_10_TIFF_CHLV95_LN02_2600_1196
## min value : 623.3814
## max value : 858.2705
And calling plot
on our object visualizes it spatially.
plot(swissalti3d)
//todo add method for rasters with multiple layers