Importing and exporting data

library(terra)
## terra 1.7.78

Read tif data

elevation <- rast("C:/Users/154455/Dropbox/2.dAILYr/R terra/data/2019/Landcover2019.TIF")
elevation
## class       : SpatRaster 
## dimensions  : 4841, 5899, 1  (nrow, ncol, nlyr)
## resolution  : 98.30178, 98.30178  (x, y)
## extent      : 207920.7, 787802.9, 1149973, 1625852  (xmin, xmax, ymin, ymax)
## coord. ref. : WGS 84 / UTM zone 48N (EPSG:32648) 
## source      : Landcover2019.TIF 
## name        : Landcover2019

Update Data

names(elevation) <- "Altitude" 

Plot Elevation

plot(elevation)

Lulc data

lulc_2019 <- rast("C:/Users/154455/Dropbox/2.dAILYr/R terra/data/2023/Landcover2023.TIF") 

Plot Lulc data

plot(lulc_2019, type = "classes")

Update class_name

class_name <- c(
  "Roads",
  "Built-up areas",
  "Water Bodies and rivers",
  "Wetlands",
  "Dry bare area",
  "Bare crop fields",
  "Low vegetation areas",
  "High vegetation areas",
  "Forested areas")

Update color

class_color <- c("#070401", "#c84639", "#1398eb","#8bc2c2",
                 "#dc7b34", "#a6bd5f","#e8e8e8", "#4fb040", "#35741f")
plot(lulc_2019,
     type = "classes",
     levels = class_name,
     col = class_color,
     plg = list(cex = 0.7) 
     )

Reference: