Work code - see the slides for the final code.

cf. 
- https://r-spatial.org/r/2018/10/25/ggplot2-sf.html
- https://paleolimbot.github.io/ggspatial/

ggplot does OK.

```{r}
library(tidyverse)
library(sf)

library(rnaturalearth)
library(rnaturalearthdata)

# world is a simple feature collection.
world <- ne_countries(scale = "medium", returnclass = "sf")
cuba <- ne_countries(scale = "medium", country = "Cuba", returnclass = "sf")

world %>%
  ggplot() +
    geom_sf() #+
    #coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97))

cuba %>%
  ggplot() +
    geom_sf() +
    annotation_scale(location = "bl") +
    annotation_north_arrow(location = "tr")  
```


ggspatial adds ggplot-compatible mapping features.

```{r}
library(ggspatial)

world %>%
  ggplot() +
    annotation_map_tile(type = "osm") +
    geom_sf() +
    coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97))
```

```{r}
havana <- st_point(c(-82.366592, 23.113592)) %>%
  st_sfc(crs = 4326)

havana <- data.frame(
  x = c(-82.366592),
  y = c(23.113592),
  city = c("Havana")
)

cuba %>%
  ggplot() +
    annotation_map_tile(type = "osm", zoomin = 0) +
    geom_sf(alpha = 0.5) +
    geom_sf(data = havana, color="red") +
    coord_sf(xlim = c(-82.45, -82.25), ylim = c(23.04, 23.17))
```


```{r}
library(ggspatial)

world %>%
  ggplot() +
    geom_sf() +
    coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97)) +
    geom_sf_text(aes(label = admin)) +
    annotation_scale(location = "bl") +
    annotation_north_arrow(location = "tr") +
    annotate(geom = "text", x = -90, y = 26, label = "Gulf of Mexico", 
             fontface = "italic", color = "grey22", size = 5)

```

```{r}
cities <- data.frame(
  x = c(-63.58595, 116.41214), 
  y = c(44.64862, 40.19063), 
  city = c("Halifax", "Beijing")
)

ggplot(cities, aes(x, y)) +
  annotation_map_tile(type = "stamenwatercolor") +
  geom_spatial_point() +
  geom_spatial_label_repel(aes(label = city), box.padding = 1) +
  coord_sf(crs = 3995)
```
