0

我正在尝试将河流数据添加到下面的这张地图中

asia_cropped <- st_crop(world, xmin = 100, xmax = 110,
                      ymin = 7, ymax = 24) #cropping map
SEA <- ggplot() + geom_sf(data = asia_cropped) + theme_bw() + #south east asia
annotate(geom = "text", x = 107, y = 8, label = "South China Sea", #adding S' China sea  
       fontface = "italic", color = "grey22", size = 4)

rivers50 <- ne_download(scale = 50, type = 'rivers_lake_centerlines', category = 'physical') #Rivers data 

我的目标是制作一张覆盖河流数据(主要是湄公河)的东南亚地图,但我不确定如何将“rivers50”与“SEA”合并

4

1 回答 1

1

您需要通过(如果您想与 ggplot 一起使用)将其转换rivers50为 sf,然后您可以使用.st_as_sfgeom_sf

library(sf)
library(tidyverse)
library(maps)
library(ggspatial)
library(rnaturalearth)
library(rnaturalearthdata)

world <- ne_countries(scale = "medium", returnclass = "sf")
asia_cropped <- st_crop(world, xmin = 100, xmax = 110,
                        ymin = 7, ymax = 24) #cropping map

rivers50 <- ne_download(scale = 50, type = 'rivers_lake_centerlines', category = 'physical') 

rivers_cropped <- st_crop(st_as_sf(rivers50), xmin = 100, xmax = 110,
                          ymin = 7, ymax = 24)

ggplot() + geom_sf(data = asia_cropped) + theme_bw() + #south east asia
  annotate(geom = "text", x = 107, y = 8, label = "South China Sea", #adding S' China sea  
           fontface = "italic", color = "grey22", size = 4)  + 
  geom_sf(data = rivers_cropped, col = 'blue')

于 2021-04-03T21:22:28.347 回答