Polar/Stereographic R 中的地图

Polar/Stereographic map in R

我正在尝试制作与此类似的立体地图:

我想做的是添加:

  1. 坐标
  2. 格线

这可以在 base 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)                                                                                                            

wm <- spTransform(wm, CRSobj = CRS(proj))
plot(wm)

这是一张复制起来相当复杂的地图,使其工作所需的所有细节似乎超出了单个问题的范围。但是,这就是您需要的大部分内容。

在 ggplot 中执行此操作 使用基本图形更容易。然而,这是一个相当复杂的图表。

我不得不使用一些 hack 来让它工作。特别是,从 coord_map 生成的轴并没有在图的边缘结束,所以我不得不手动删除轴,然后使用下面的 geom_textgeom_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")

使用 PlotSvalbard 包的替代解决方案:

# devtools::install_github("MikkoVihtakari/PlotSvalbard") ## Run once

library(PlotSvalbard)

basemap("panarctic", limits = 60)

该函数还绘制了测深图:

basemap("panarctic", limits = 60, bathymetry = TRUE)

检查 the user manual for further features. Plotting data is possible using ggplot2 syntax. Use the add_land function to add land shapes on top of the raster you need to plot (needs to be in the same projection than the Pan-Arctic basemaps, see map_projection("panarctic")). The transform_coord 函数可能有助于转换投影。