1

Create a matrix with 8 rows and 8 columns filled with random numbers between 1 and 1000.
You can create the numbers using the sample() function.

2

Now, use this matrix to create a raster layer and plot it.
The terra::rast() function can be fed with matrices to create a raster layer.

The terra::rast() function can not only be used to create raster data on the fly, which is also quite boring. Instead, we can use it to import already prepared data.

3

Import one of the raster .tiff files in the ./data folder of the workshop directory.
Make sure your file paths are set correctly. You can check them with getwd(). Setting is done with setwd().

4

Import the data on immigrants and inhabitants. Create a new layer showing the proportion of immigrants in each grid cell between 0 and 1. Next, apply z-standardization and dichotomize the data to get information about which grid cells deviate from the overall mean. Plot both “versions” of the data to see how they compare.
You can handle raster layers as any simple data table using +, -, or / operators. Z-standardization can be applied using the terra::scale() function.