Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate terra - maps #490

Closed
Beedmoser opened this issue Nov 27, 2023 · 3 comments
Closed

Animate terra - maps #490

Beedmoser opened this issue Nov 27, 2023 · 3 comments

Comments

@Beedmoser
Copy link

Hi
I try to animate a map. I have one single spatvector. I can plot multiple maps with facet_wrap (vars(Jahr)) but gganimate throws an error when I try to add transition_time(Jahr): Fehler: arguments have different crs

Then I noticed that this error is thrown by all attempts to gganimate a map using ready made code I downloaded, like

library(tidyverse)
library(rnaturalearth)
library(rnaturalearthdata)
library(gganimate) # also needs transformr

set.seed(1234)

ww <- ne_countries(scale = "medium", returnclass = "sf")

ll <- ww$name %>% length

val <- sample(c("a","b","c","d"), ll, replace=T)
bb <- ne_download(type = "wgs84_bounding_box", category = "physical",
returnclass = "sf")
ww <- ww %>% mutate(value=val)

newdf <- lapply(seq_len(5), function(i) {
new <- ww
new$group <- seq_len(nrow(new))
new$value <- sample(letters[1:4], nrow(new), replace = TRUE)
new$time <- i
new
})
newdf <- do.call(rbind, newdf)

gpl1 <- ggplot(data = newdf) +
geom_sf(aes(fill=value, group = group), col = "black", lwd = 0.3 )+
xlab(NULL) + ylab(NULL) +
ggtitle("World Export of Merchandise", subtitle = "{frame_time}")+
geom_sf(data = bb, col = "grey", fill = "transparent") +
theme(plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = 'white'),
panel.grid.major = element_line(colour = "grey"),
legend.position="top",
plot.title = element_text(lineheight=.8, size=24, face="bold",
vjust=1),
legend.text = element_text(vjust=.4,lineheight=1,size = 14),
legend.title = element_text(vjust=1,lineheight=1, size=14,
face="bold" )) +
transition_time(time)
ani <- animate(gpl1)

What could be the problem, given R and all packages are up-to-date? Also the Error does not make sense to me. How can I have multiple crs in one spatVector?

@ptr-64
Copy link

ptr-64 commented Jan 22, 2024

Hi
This is a known issue. For now try to downgrade transformr to 0.1.3. This can be done by devtools::install_version("transformr", version = "0.1.3") in a fresh session.

@Beedmoser
Copy link
Author

Beedmoser commented Jan 23, 2024 via email

@ptr-64
Copy link

ptr-64 commented Jan 24, 2024

If your issue got solved you might consider closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants