dieghernan / tidyterra

tidyverse and ggplot2 methods for terra spatial objects

Home Page:https://dieghernan.github.io/tidyterra/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message in plot

Edward62 opened this issue · comments

RE: https://dieghernan.github.io/tidyterra/articles/tidyterra.html

Contour lines for a specific layer

f_volcano <- system.file("extdata/volcano2.tif", package = "tidyterra")
volcano2 <- rast(f_volcano)

ggplot() +
geom_spatraster(data = volcano2) +
geom_spatraster_contour(data = volcano2, breaks = seq(80, 200, 5)) +
scale_fill_whitebox_c() +
coord_sf(expand = FALSE) +
labs(fill = "elevation")

Running this syntax results in
"Error in [.data.frame(data, c("x", "y", "size", "colour", "linetype")) :
undefined columns selected"

I'm unsure why this code results in an error and how to best fix it.

Thank you.

What are your installed versions of tidyterra, terra, and ggplot2?
It works for me using tidyterra 0.4.0, terra dev 1.7-18,ggplot2 3.4.1, and R 4.2.2 on Win10

See #67 seems to be the same issue solved after updating all the packages (as also suggested by @Rapsodia86 ). Can you try? Also adding the session info of your script would be very helpful

Is this still an issue @Edward62 ?