R 显示白天和夜间区域的世界地图
我试图使用R 显示白天和夜间区域的世界地图,r,ggplot2,gis,great-circle,geosphere,R,Ggplot2,Gis,Great Circle,Geosphere,我试图使用ggplot向世界地图添加一条白天/夜间线,以指示白天和夜间区域;大概是这样的: 计划是在24小时周期内为我的地图设置动画,如下所示: 上面的动画是用正弦波实现的,我知道这是完全不准确的。我知道geosphere::gcIntermediate可以让我画出大圆线,如下所示: library(ggplot2) library(ggthemes) library(geosphere) sunPath1 <- data.frame(gcIntermediate(c(-179, -
ggplot
向世界地图添加一条白天/夜间线,以指示白天和夜间区域;大概是这样的:
计划是在24小时周期内为我的地图设置动画,如下所示:
上面的动画是用正弦波实现的,我知道这是完全不准确的。我知道geosphere::gcIntermediate
可以让我画出大圆线,如下所示:
library(ggplot2)
library(ggthemes)
library(geosphere)
sunPath1 <- data.frame(gcIntermediate(c(-179, -30), c(0, 30), n=100))
sunPath2 <- data.frame(gcIntermediate(c(0, 30), c(179, -30), n=100))
sunPath <- rbind(sunPath1, sunPath2)
ggplot(sunPath) +
borders("world", colour = "gray95", fill = "gray90") +
geom_ribbon(aes(lon, ymax = lat), ymin=-180, fill="black", alpha=0.2) +
theme_map()
库(ggplot2)
图书馆(主题)
图书馆(地球圈)
sunPath1我在@jazzurro的帮助下解决了这个问题,他将我指向R包。我已经将他们的javascript插件移植到R,以便在交互式传单地图之外使用
功能可用
以下是24小时动画的示例:
library(dplyr)
library(ggplot2)
library(ggthemes)
library(gganimate)
library(animation)
terminatorLatLon <- lapply(seq(0, 23, 1), function(x) {
t0 <- as.POSIXct(Sys.Date()) + (60*60*x)
terminator(t0, -180, 190, 0.5) %>%
mutate(frame = x)
}) %>%
plyr::rbind.fill()
chart <- ggplot(terminatorLatLon, aes(frame = frame)) +
borders("world", colour = "gray90", fill = "gray85") +
geom_ribbon(aes(lat, ymax = lon), ymin = 90, alpha = 0.2) +
coord_equal(xlim = c(-180, 190), ylim = c(-58, 85), expand = 0) +
theme_map()
gganimate(chart, interval = 0.1, ani.width=1000, ani.height=600, filename = "terminator-animation.gif")
库(dplyr)
图书馆(GG2)
图书馆(主题)
库(gganimate)
图书馆(动画)
终结者地图集%
plyr::rbind.fill()
查特也许是对你有帮助的帖子之一。谢谢@jazzurro-我以前没见过这篇帖子,它看起来非常有用!不客气。如果您使用传单
包装,您可以指明白天和黑夜。我不知道你怎样才能使它成为动画。如果你好奇的话,可以看看。这也是一个很好的资源,谢谢。了解“终结者”一词也有助于找到解决方案!