Work code - see the slides for the final code.

cf. 
- https://geocompr.robinlovelace.net
- https://mhweber.github.io/AWRA_2020_R_Spatial

```{r}
library(leaflet)
popup = c("Calvin University", "University of Colorado", "ITRI, University of Brighton", "CSIRO, Sydney", "Pella, IA")
leaflet() %>%
  addProviderTiles("NASAGIBS.ViirsEarthAtNight2012") %>%
  addMarkers(lng = c(-85.670006, -105.270546, -0.152778, 151.209900, -92.916423),
             lat = c(42.963795, 40.014984, 50.827778, -33.865143, 41.408059), 
             popup = popup)
```

```{r}
library(sf)            # classes and functions for vector data
library(terra)         # classes and functions for raster data
library(spData)        # load geographic data
library(spDataLarge)   # load larger geographic data
```

```{r}
world
plot(world["geom"])
```

```{r}
st_crs(world)
crs(world)
```


```{r}
library(tmap)
library(rcartocolor)
library(spDataLarge)
library(terra)

# data read ---------------------------------------------------------------
cla_raster = rast(system.file("raster/srtm.tif", package = "spDataLarge"))

# plots create ------------------------------------------------------------
rast_srtm = tm_shape(cla_raster) +
  tm_raster(palette = carto_pal(7, "Geyser"),
            title = "Elevation (m)", style = "cont") 

tmap_arrange(rast_srtm)
```

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

# Plot the base world geography.
plot(world["continent"], reset = FALSE)

# Add census data.
cex = sqrt(world$pop) / 10000
world_cents =
  st_centroid(world,
              of_largest = TRUE)
plot(st_geometry(world_cents),
     add = TRUE,
     cex = cex)
```

