背景
我正在努力尝试创建一个天体Map的基础上给定的位置和日期在R。
理想情况下,视觉效果如下所示:
(Source)
我确实看到了this blog,它利用了D3 Celestial Maps,对创建下面的视觉效果非常有帮助。
library(sf)
library(tidyverse)
theme_nightsky <- function(base_size = 11, base_family = "") {
theme_light(base_size = base_size, base_family = base_family) %+replace%
theme(
# Specify axis options, remove both axis titles and ticks but leave the text in white
axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text = element_text(colour = "white",size=6),
# Specify legend options, here no legend is needed
legend.position = "none",
# Specify background of plotting area
panel.grid.major = element_line(color = "grey35"),
panel.grid.minor = element_line(color = "grey20"),
panel.spacing = unit(0.5, "lines"),
panel.background = element_rect(fill = "black", color = NA),
panel.border = element_blank(),
# Specify plot options
plot.background = element_rect( fill = "black",color = "black"),
plot.title = element_text(size = base_size*1.2, color = "white"),
plot.margin = unit(rep(1, 4), "lines")
)
}
# Constellations Data
url1 <- "https://raw.githubusercontent.com/ofrohn/d3-celestial/master/data/constellations.lines.json"
# Read in the constellation lines data using the st_read function
constellation_lines_sf <- st_read(url1,stringsAsFactors = FALSE) %>%
st_wrap_dateline(options = c("WRAPDATELINE=YES", "DATELINEOFFSET=180")) %>%
st_transform(crs = "+proj=moll")
# Stars Data
url2 <- "https://raw.githubusercontent.com/ofrohn/d3-celestial/master/data/stars.6.json"
# Read in the stars way data using the st_read function
stars_sf <- st_read(url2,stringsAsFactors = FALSE) %>%
st_transform(crs = "+proj=moll")
ggplot()+
geom_sf(data=stars_sf, alpha=0.5,color="white")+
geom_sf(data=constellation_lines_sf, size= 1, color="white")+
theme_nightsky()
我的问题
我设法在R中创建的图像是(据我所知)整个天体图,我怎样才能得到天体图的一个子集来表示我的相对位置呢?
1条答案
按热度按时间dgenwo3n1#
我认为这里需要一个正投影: