Skip to content

facet_grid #152

@danbebber

Description

@danbebber

I've posted this on Stack Overflow: tidyterra allows use of facet_wrap(~lyr) to plot multiple spatial raster layers in one figure.

library(terra)
library(ggplot2)
library(tidyterra)
x <- rast(array(data = rnorm(120,0,1), dim=c(5,5,4)))
names(x) <- c("A_1", "B_1", "A_2", "B_2")
ggplot() +
  geom_spatraster(data = x) +
  facet_wrap(~lyr)

Is there any way of implementing facet_grid in tidyterra so that, in the case above for example, the rows would be labelled 1 and 2, and columns would be labelled A and B?
This would require a spatraster object to have more than one attribute (the name of the layer) associated with it, I guess. I don't know if a data.frame can be associated with a spatraster object in which each row refers to a layer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions