The trajectory map consistently displays an incorrect colour scheme. This happens because tidyterra assigns colours based on the number of classes in the categorical raster. If the colour palette is assigned according to a column in the raster attribute table that doesn't match the values in the raster file, tidyterra will display the incorrect colour scheme.
Potential Solution
Before plotting, the luc_trajectory_mapspatres object should be re-classified into the 9 classes below:
Analisis alur penggunaan lahan (Deforestasi dan Degradasi)
# Create the lookup table
color_traj <- tribble(
~ID_traj, ~trajectory, ~color_pallette,
1, "Stable natural forest", "#006400", # Dark Green
2, "Recovery to tree cropping", "#8B4513", # Saddle Brown
3, "Recovery to forest", "#228B22", # Forest Green
4, "Recovery to agroforest", "#4B0082", # Indigo
5, "Other", "#808080", # Grey
6, "Loss to logged-over forest", "#F28500", # Dark Olive Green
7, "Loss to infrastructure", "#FF0000", #Red
8, "Loss to cropland", "#FFFF00", # Yellow
9, "Loss to bare land and abandoned", "#ffb6c1", # Pink
)
Problem
The trajectory map consistently displays an incorrect colour scheme. This happens because
tidyterra
assigns colours based on the number of classes in the categorical raster. If the colour palette is assigned according to a column in the raster attribute table that doesn't match the values in the raster file,tidyterra
will display the incorrect colour scheme.Potential Solution
Before plotting, the
luc_trajectory_map
spatres
object should be re-classified into the 9 classes below:https://github.com/icraf-indonesia/LUMENSR/blob/b60dcc0ea804027def84157bddd4ef44ad9fcf82/R/ques_pre_trajectory.R#L26-L33
Analisis alur penggunaan lahan (Deforestasi dan Degradasi)
Originally posted by @dindiarto in https://github.com/icraf-indonesia/LUMENSR/issues/19#issuecomment-1685509700