-
Notifications
You must be signed in to change notification settings - Fork 16
/
06-Maps.Rmd
112 lines (94 loc) · 5.38 KB
/
06-Maps.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Maps
**Learning Objectives:**
- Plot simple maps using `geom_polygon()`
- Using *simple features* `sf` to plot GIS data `geom_sf()`
- Work with map projections and underlying `sf` data structure
- Draw maps using Raster data
Plotting geospacial data is a common visualization task. The process may require spcialized tools. You can decompse the problem into two paths:
- Using one data source to draw a map (if you have GIS data)
- Adding metadata from another information source to the map (more common with relation to geographic areas)
> NOTE: X = Longitude, Y=Latitude. When pronounced "Lat/Lon" it is actually measured as Y/X. Not confusing....just keeping with vocabulary and measurements!
## Polygon Maps
The simplest approach to mapping is using geom_polygon(). This forms bounderies around regions.
```{r 06-mi-countries, include=TRUE}
library(ggplot2)
mi_counties <- map_data("county", "michigan") %>%
select(lon = long, lat, group, id = subregion)
head(mi_counties)
```
In this data set we have four variables:
- `lat`: Latitude of the vertex (as measured by horizontal paths)
- `long`: Longitude of the vertex (as measured by vertical paths)
- `id`: name of the region
- `group`: unique identifier for contiguous areas within a region
```{r 06-coord_quickmap(), include=TRUE}
ggplot(mi_counties, aes(lon, lat)) +
geom_point(size = .25, show.legend = FALSE) +
coord_quickmap()
ggplot(mi_counties, aes(lon, lat, group = group)) +
geom_polygon(fill = "white", colour = "grey50") +
coord_quickmap()
```
In this plot, `coord_quickmap()` is used to adjust the axes to ensure longitude and latitude are rendered on the same scale
For a more advanced use of ggplot2 for mapping, we'll see the use of `geom_sf()` and `coord_sf()` to handle spatial data specified in simple features format.
## Simple Features Maps
You *can* use the above examples...but not real world pratical. Instead, most GIS data is written as *simple features* and produced by the (Open Geospatial Consortium]https://www.ogc.org/)
### Layered Maps
### Labelled Maps
### Adding Other Geoms
## Map Projections
## Working with `sf` Data
## Raster Maps
## Data Sources
## Meeting Videos
### Cohort 1
`r knitr::include_url("https://www.youtube.com/embed/8-_iLnAogss")`
<details>
<summary> Meeting chat log </summary>
```
00:11:25 June Choe: hello!
00:15:21 SriRam: Hi all, I am new here, I came to know about this from ISLR book club
00:16:14 Stan Piotrowski: Great have to have you here, SriRam! Some of us are also in the ISLR book club and I think this is a nice complement to that material
00:25:26 June Choe: I'd like to see the error!
00:26:54 June Choe: I think you'd have to add a geom_labe() layer
00:27:08 June Choe: but as Stan said it'll render text at every point
00:27:29 June Choe: after polygon would draw it on top
00:33:36 Michael Haugen: Reminds me of a Flight of the Concords episode
00:35:04 SriRam: 23.5
00:40:09 SriRam: It would be incorrect data to have multiple geometries on same record
00:47:44 Lydia Gibson: It’s spelled right… or at least that’s how it’s spelled in the book
00:48:16 June Choe: hm maybe the sf_label and sf_text layers also need to take the geometry aesthetic
00:49:02 June Choe: label.padding I think is from geom_label (the white space between text and bounding box)
00:52:51 Federica Gazzelloni: viridis
00:53:30 Federica Gazzelloni: scale_color_viridis()
00:53:42 Federica Gazzelloni: scale_fill_viridis()
00:54:01 SriRam: I think viridis is better for continuous values
00:54:57 Federica Gazzelloni: viridian package: https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
00:55:08 Federica Gazzelloni: viridis package: https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
00:55:51 Federica Gazzelloni: more: https://www.rdocumentation.org/packages/viridis/versions/0.5.1/topics/scale_color_viridis
00:56:21 Michael Haugen: David Robinson uses scale_fill_viridis_c() for a map in his most recent Tidy Tuesday Screen cast. See around 23minute mark: Tidy Tuesday live screencast: Analyzing registered nurses in R. https://www.youtube.com/watch?v=UVmxHb2Daeo&t=486s
01:12:20 Lydia Gibson: Thank you Ryan!!
01:12:34 Federica Gazzelloni: thanks Ryan
01:12:54 Stan Piotrowski: Thanks Ryan!
```
</details>
`r knitr::include_url("https://www.youtube.com/embed/RiACZPhm53Y")`
<details>
<summary> Meeting chat log </summary>
```
00:09:20 priyanka gagneja: sorry everyone I just joined
00:09:38 Federica Gazzelloni: Hello!
00:10:02 priyanka gagneja: and will probably be a little in and out .. got a not so happy baby today at home
00:18:11 Stan Piotrowski: I need to take off for a conflict that just came up. Catch up with you all on slack!
00:20:46 SriRam: It is the image product ID
00:21:07 SriRam: All the IDE’s
00:21:50 Kent Johnson: The IDE codes are defined here: https://ropensci.github.io/bomrang/reference/get_available_imagery.html
00:27:32 SriRam: The process is called geo-referencing
00:27:58 SriRam: And image is called a geo-referenced image
00:31:33 SriRam: Yes, it is a reference system
00:31:38 SriRam: A coordinate reference
00:33:04 Federica Gazzelloni: this is the bit that makes the reference: crs = st_crs(sat_vis)
00:49:27 Jiwan Heo: something just came up, and have to leave. See you all next week!
00:59:58 priyanka gagneja: I am signing off now , can someone please address and sign off on my behalf. I will send a msg later on slack
```
</details>