Phi*_*tte 2 gis maps r cartography ggplot2
我试图生成类似于此的立体图:
我想要做的是添加:
这可以在基础R或ggplot2中.任何帮助表示赞赏.
到目前为止我的尝试
library(rgdal)
library(raster)
proj <- "+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs"
data("wrld_simpl", package = "maptools")
wm <- crop(wrld_simpl, extent(-180, 180, 45, 90))
plot(wm)
Run Code Online (Sandbox Code Playgroud)
wm <- spTransform(wm, CRSobj = CRS(proj))
plot(wm)
Run Code Online (Sandbox Code Playgroud)
这是一个非常复杂的重现地图,使其工作所需的所有细节都超出了单个问题的范围.但是,这是您需要的大部分内容.
使用基本图形更容易在ggplot中执行此操作.但是,这是一个非常复杂的图表.
我不得不使用一些黑客来让它工作.特别是,生成的轴coord_map没有在绘图的边缘结束,因此我不得不手动删除轴,然后使用下面的geom_text和geom_segment行重新创建它们.
library(rgdal)
library(raster)
library(ggplot2)
# Defines the x axes required
x_lines <- seq(-120,180, by = 60)
ggplot() +
geom_polygon(data = wm_ggplot, aes(x = long, y = lat, group = group), fill = "grey", colour = "black", alpha = 0.8) +
# Convert to polar coordinates
coord_map("ortho", orientation = c(90, 0, 0)) +
scale_y_continuous(breaks = seq(45, 90, by = 5), labels = NULL) +
# Removes Axes and labels
scale_x_continuous(breaks = NULL) +
xlab("") +
ylab("") +
# Adds labels
geom_text(aes(x = 180, y = seq(55, 85, by = 10), hjust = -0.2, label = paste0(seq(55, 85, by = 10), "°N"))) +
geom_text(aes(x = x_lines, y = 39, label = c("120°W", "60°W", "0°", "60°E", "120°E", "180°W"))) +
# Adds axes
geom_hline(aes(yintercept = 45), size = 1) +
geom_segment(aes(y = 45, yend = 90, x = x_lines, xend = x_lines), linetype = "dashed") +
# Change theme to remove axes and ticks
theme(panel.background = element_blank(),
panel.grid.major = element_line(size = 0.25, linetype = 'dashed',
colour = "black"),
axis.ticks=element_blank()) +
labs(caption = "Designed by Mikey Harper")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |