在正投影中绘制2d密度估计时,我得到了人工制品。问题是轮廓线不会在日期线处缠绕。这可以在ggplot2中完成吗?
library(tidyverse)
# points on a map, longitude between -180 and 180
df = data_frame(lon=c(rnorm(100, -180, 50),
rnorm(100, 180, 50)),
lat=rnorm(200, 60, 10)) %>%
filter(lon > -180, lon < 180)
# 2d density, orthographic projection
ggplot(data=df) +
coord_map('ortho') +
geom_point(aes(x=lon, y=lat)) +
stat_density2d(aes(x=lon, y=lat))
答案 0 :(得分:2)
不确定它是否正是您所寻找的:
m <- mapproject(df$lon, df$lat, projection="orthographic", parameters=NULL,
orientation=NULL)
ggplot(data=as.data.frame(cbind(m$x, m$y))) +
geom_point(aes(x=V1, y=V2)) +
geom_density2d(aes(x=V1, y=V2))