bleutner / RStoolbox

Remote Sensing Data Analysis in R 🛰
267 stars 82 forks source link

ggR with classified raster #93

Closed aloboa closed 1 year ago

aloboa commented 1 year ago

Given:

#using terra
v <- values(rast(RStoolbox::rlogo))
k <- kmeans(v,4)
c <-  rast(RStoolbox::rlogo)[[1]]
values(c) <- k$cluster
ggR(c, geom_raster=TRUE) + 
  scale_fill_brewer(palette = "Set1")
Error: Continuous value supplied to discrete scale

and have to use, eg:

ggR(c, geom_raster=TRUE) + 
  scale_fill_gradientn(colours = terrain.colors(4))

Is there a way to actually use qualitative color palettes with classified rasters?

aloboa commented 1 year ago

The problem is when I use as.factor() with my data. Not an issue here either.