Closed Saadi4469 closed 3 years ago
Hello,
This functionality is not included in rasterVis
. You may try RStoolbox::ggRGB
or terrainr::geom_spatial_rgb
.
There is also terra::RGB2col
to go from RGB to a single layer with a color-table. But I do not think that rasterVis
looks at color tables; and I am not sure if any other package does that for ggplot
mapping.
Thank you both, and also thanks a bundle for making this package. Normally, I had to first convert a raster into a df to plot with ggplot2, and for high resolution rasters, that's inefficient in terms of memory use. But, your package maybe also does that in the background, but is so well optimized that I don't run into any memory issues no matter how big the raster is.
Regular sampling is used for large rasters.
With raster
this is used
maxpixels=50000
x <- raster::sampleRegular(x, maxpixels, asRaster = TRUE)
And with terra
x <- terra::spatSample(x, maxpixels, "regular", as.raster = TRUE)
Hello,
How can I plot an RGB raster with gplot? For plotting RGB rasters, I usually use plotRGB from the raster package. But, now I am trying to plot it via gplot so I can add other ggplot2 functions in the plot object.
Thank you,