[R-sig-Geo] Using facet_wrap with geom_stars for a stacked raster

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Tue Jun 1 18:49:44 CEST 2021



On 01/06/2021 18:43, Manuel Spínola wrote:
> Dear list members,
> 
> I am trying to use facet_wrap with geom_stars but I don't know how to
> specify the variable argument in the facet_wrap function (I know is not
> "band"), and also, how to change the labels of the strip names?
> 
> r <- read_stars(system.file("external/test.grd", package="raster"))
> 
> s1 <- c(r, r*2)
> 
> ggplot() +
>    geom_stars(data = s1) +
>    coord_equal() +
>    facet_wrap(~ band)
> 

Try:

ggplot() +
   geom_stars(data = merge(s1)) + f
   facet_wrap(~attributes) +
   coord_equal()


c() binds attributes, merge() merges them into a dimension.
-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081



More information about the R-sig-Geo mailing list