-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanswers-1_xy.Rmd
55 lines (40 loc) · 1.42 KB
/
answers-1_xy.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
title: "Exercise 1 Answers: Georeferencing"
output: html_notebook
---
```{r}
library(tidyverse)
library(sf)
library(leaflet)
library(mapview)
```
## Load Data
```{r readdata}
xy_locations <- read_csv("data/mockaroo_latlon.csv")
```
### Plot XY on the Map
There are at least two methods, using `mapview` to plot XY coordinates on a map. In the blank code-chunks, below, write code to demonstrate at least one of those methods. Use the `4269` coordinate reference system.
In the example below I use the _S4 Method for XY_ (in case you want to consult the documentation. https://r-spatial.github.io/mapview/reference/mapView.html )
```{r makemap1}
mapview(xy_locations, xcol = "Longitude", ycol = "Latitude", crs = 4269, grid = FALSE)
```
Write code to demonstrate the other method demonstrated in 01_georeference.html
Below, I will first use the `sf` package to convert a tibble to an _sf tibble_.
```{r alt-makemap}
xy_sf <- st_as_sf(xy_locations, coords = c("Longitude", "Latitude"), crs=4326)
mapview(xy_sf)
```
## High Contrast & Save
1. Create a high contrast (black and white) map.
1. Save the file as a .jpeg file.
```{r contrastymap}
mymap <- mapview(xy_sf,
map.types = "Stamen.Toner",
legend = FALSE,
col.regions = "yellow",
color = "red",
alpha.regions = 1,
lwd = 3)
mapshot(mymap, file = "mymap.jpeg")
mymap
```