Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created November 19, 2025 02:39
Show Gist options
  • Select an option

  • Save mdsumner/5c5bc304e38575368410faef723dbc26 to your computer and use it in GitHub Desktop.

Select an option

Save mdsumner/5c5bc304e38575368410faef723dbc26 to your computer and use it in GitHub Desktop.
sentinel_palette <- function() {
  as.data.frame(list(value = 0:11, class = c("No Data (Missing data)", "Saturated or defective pixel", 
                                                   "Topographic casted shadows (called Dark features/Shadows for data before 2022-01-25)", 
                                                   "Cloud shadows", "Vegetation", "Not-vegetated", "Water", "Unclassified", 
                                                   "Cloud medium probability", "Cloud high probability", "Thin cirrus", 
                                                   "Snow or ice"), col = c("#000000", "#ff0000", "#2f2f2f", "#643200", 
                                                                           "#00a000", "#ffe65a", "#0000ff", "#808080", "#c0c0c0", "#ffffff", 
                                                                           "#64c8ff", "#ff96ff")))
  
}


cl <- sentinel_palette()
r <- terra::rast(x$scl_tif)  ## some scl or SCL .tif from Sentinel 
coltab(r) <- dplyr::transmute(cl, value, col)
levels(r) <- dplyr::transmute(cl, ID = value, category = class)
@mdsumner
Copy link
Author

flawless!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment