Adding rivers to a map with rnaturalearth

1.5k Views Asked by At

I am trying to add river data to this map below

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 

My goals is to have a map of SE Asia with river data overlaid (Mainly the Mekong) but I am unsure how to merge "rivers50" with "SEA"

1

There are 1 best solutions below

1
On

You'll need to convert the rivers50 to sf via st_as_sf (if you want to use with ggplot) then you can add it to your map with geom_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')