Ewoud Brouwer
Ewoud Brouwer

Reputation: 45

How to create a map of Europe with the European part of Russia included in R?

I want to plot data of number of passengers from the Holland America Line. I created a shapefile with Eurostat, but Russia isn't included. The thing is, that I don't want a map with whole Russia, but only the European part like below.

enter image description here

Is there a shapefile available with only the "European" Part of Russia?

The dataset looks like this:

region Freq ID
Austria 7095 AT
Belarus 1 BY
Belgium 3 BE
Croatia 103 HR
Czech Republic 27 CZ
France 3374 FR
Germany 4132 DE
Greece 1 GR
Hungary 20 HU
Italy 2 IT
Latvia 34 LV
Lithuania 183 LT
Luxembourg 4 LU
Netherlands 29123 NL
Poland 2409 PL
Romania 171 RO
Russia 1469 RU
Slovakia 1 SK
Switzerland 4 CH
Ukraine 60 UK

With the following code I managed to create a map of Europe, excluding Russia. But, is there a possibility to get the geometrics of the Europe part of Russia?

# Get geometrics
Europe_shp <- get_eurostat_geospatial(resolution = 10, 
                                      nuts_level = 0, 
                                      year = 2016)
                                      
# Merge passenger data data with geometrics
European_Countries_1907 <- merge(country_passengers_1907_europe_code, Europe_shp, all.x = TRUE, all.y = TRUE, by.x = "ID", by.y = "id")

# Create plot of Europe
vector_colors_gradient_2 <- c("#fff997", "#ffd983", "#ffb97b", "#f89b79","#e6807c", "#cd6a80", "#ad5983", "#874c82", "#5d427b", "#2b386f")

Map_1907 <- European_Countries_1907 %>% 
  ggplot(aes(fill = log10(Freq))) +
  aes(geometry = geometry) +
  geom_sf(size = 0.1, color = "#F3F3F3") +
  scale_fill_gradientn(colours = vector_colors_gradient_2,
                       labels = ~scales::comma(10^.x)) +
  scale_x_continuous(limits = c(-10, 27)) +
  scale_y_continuous(limits = c(33, 70)) +
  labs(
    title = "Travellers from Europe",
    subtitle = "Number of HAL Passengers in 1907",
    caption = "Data: Stadsarchief Rotterdam",
    fill = "Number of Passengers"
  ) +
  theme_void() +
  theme(plot.margin = margin(20, 0, 20, 20))
Map_1907

Upvotes: 2

Views: 1283

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 173803

As tjebo says, the rnaturalearth package is a great source of geographic data. You can get the entire world as a shapefile and perform a left join with your own data. Replicating the map above requires plotting with crs set to EPSG 3035 and appropriate axis limits:

library(rnaturalearth)
library(sf)
library(ggplot2)

world <- ne_countries(scale = 50, returnclass = 'sf')

ggplot(world) + 
  geom_sf(aes(fill = continent), color = 'black') +
  geom_sf_text(aes(label = name), size = 5) +
  coord_sf(crs = st_crs(3035),
           xlim = c(2000000, 6200000), 
           ylim = c(1500000, 5500000)) +
  scale_fill_manual(values = c('#c4c0a0', NA, '#c9cc3d', '#fcd752', 
                               NA, NA, NA, NA), guide = 'none', 
                    na.value = 'white') +
  theme(panel.background = element_rect(fill = '#92c5f0'),
        panel.grid.major = element_line(linewidth = 0.1, 
                                        color = '#80808080'))

enter image description here

Upvotes: 4

Related Questions