Skip to content

Commit 654071a

Browse files
committed
tweaking language
1 parent 245e9ce commit 654071a

File tree

12 files changed

+41
-56
lines changed

12 files changed

+41
-56
lines changed

01_georeference.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Latitude and Longitude Coordinates
33
---
4-
Use the [`mapview` package](https://r-spatial.github.io/mapview/index.html) to make interactive maps. In this example, georeference Starbucks coffee shop locations in North Carolina (2012)^[[5 Visualizations in 5 Minutes](http://www.computerworld.com/article/2893271/business-intelligence/5-data-visualizations-in-5-minutes-each-in-5-lines-or-less-of-r.html). ComputerWorld.com by Sharon Machlis].
4+
Use the [`mapview` package](https://r-spatial.github.io/mapview/index.html) to make interactive maps. In this example, georeference Starbucks coffee shop locations in North Carolina (2012). ^[[5 Visualizations in 5 Minutes](http://www.computerworld.com/article/2893271/business-intelligence/5-data-visualizations-in-5-minutes-each-in-5-lines-or-less-of-r.html). ComputerWorld.com by Sharon Machlis]
55

66

77
## Load Libraries
@@ -31,18 +31,18 @@ starbucksNC %>%
3131

3232
## Make the Map
3333

34-
In this example, plot latitude (y coordinates) and longitude (x coordinates), then set the map projection^[[projection/CRS](https://guides.library.duke.edu/r-geospatial/CRS)] to a common projection standard, WGS84, via the argument `crs = 4326`.)
34+
In this example, plot latitude (y coordinates) and longitude (x coordinates). Then set the map projection^[[Projection / CRS](https://guides.library.duke.edu/r-geospatial/CRS)] to a common projection standard such as _WGS84_ via the argument `crs = 4326`.)
3535

3636
```{r map1}
3737
mapview(starbucksNC, xcol = "Longitude", ycol = "Latitude", crs = 4269, grid = FALSE)
3838
```
3939

4040
## Alternative: Transform data to Spatial object
4141

42-
Another way to plot the x & y coordinates is by transforming the starbucksNC tibble (i.e. the starbucksNC data frame) into a spacial data frame via the simple features function, `st_as_sf()`. It's important to set the [map projection](https://en.wikipedia.org/wiki/Map_projection) to a common standard, WGS84, via the argument `crs = 4326`.)
42+
Another way to plot the x & y coordinates is by transforming the starbucksNC tibble (i.e. the starbucksNC data frame) into a spacial data frame via the simple features function, `st_as_sf()`. Again, set the [map projection](https://en.wikipedia.org/wiki/Map_projection) to a common standard such as _WGS84_ via the `crs=` argument.
4343

4444
```{r convert2spacial}
45-
sbux_sf <- st_as_sf(starbucksNC, coords = c("Longitude", "Latitude"), crs=4326)
45+
sbux_sf <- st_as_sf(starbucksNC, coords = c("Longitude", "Latitude"), crs = 4326)
4646
```
4747

4848
### Now Map the sf object.

02_choropleth.Rmd

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ starbucksNC <- starbucks %>%
8080
filter(State == "NC")
8181
```
8282

83-
Convert the `starbuckNC` dataframe to a spatial (sf) object and assign the same projection as the `nc_pop` spatial object.
83+
Convert the `starbucksNC` data frame to a spatial (sf) object and assign the same projection as the `nc_pop` spatial object.
8484

8585
```{r convert2sf}
8686
starbucksNC <- st_as_sf(starbucksNC, coords = c("Longitude", "Latitude"), crs = st_crs(nc_pop))
@@ -111,7 +111,7 @@ addLogo(mymap, "images/Rfun3.png",
111111

112112
## Alaska & Hawaii - Shift
113113

114-
Shift and re-scale Alaska and Hawaii for better cartographic display of the entire US.
114+
Shift and re-scale Alaska and Hawaii for convenient cartographic display of the entire US.
115115

116116
```{r shiftgeoakhi, message=FALSE, warning=FALSE}
117117
@@ -120,20 +120,12 @@ population <- get_acs(geography = "state",
120120
geometry = TRUE,
121121
shift_geo = TRUE)
122122
123-
124-
```
125-
126-
127-
```{r buildshift, message=FALSE, warning=FALSE}
128123
mapviewOptions(legend.pos = "bottomright")
129124
mapviewOptions(leafletWidth = 800)
130-
#mapviewOptions()
131-
#mapviewOptions(default = TRUE)
132125
mapview(population, zcol = "estimate", native.crs = TRUE, crs = 5070)
133126
```
134127

135128

136-
137129
## Census
138130

139131
During the workshop I will discuss the following concepts in more detail.

032_thematic_mapping_geom_sf.Rmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ title: "Thematic Mapping with geom_sf"
44

55

66
```{r load-libraries, message=FALSE, warning=FALSE}
7-
library(tidyverse) # Tidyverse for Tidy Data
7+
library(tidyverse)
88
library(readxl)
99
library(tigris)
1010
library(sf)
1111
library(viridis)
12-
library(ggplot2)
1312
```
1413

1514

@@ -83,7 +82,7 @@ In this plot I **reversed** the _direction_ of the color scale. Reversing the c
8382

8483
Use a pleasing projection. In this case assign the CRS projection to '5070'
8584

86-
> `coord_sf(crs = 5070)`&nbsp; Help with [projection/CRS](https://guides.library.duke.edu/r-geospatial/CRS)
85+
> `coord_sf(crs = 5070)`&nbsp; Help with [projection/CRS](https://guides.library.duke.edu/r-geospatial/CRS)
8786
> `coords_sf(datum = NA)` Remove gridlines, i.e [graticules](https://en.wikipedia.org/wiki/Graticule)
8887
8988
```{r with-ggplot-geom_sf, message=FALSE, warning=FALSE}

docs/01_georeference.html

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

docs/02_choropleth.html

Lines changed: 10 additions & 16 deletions
Large diffs are not rendered by default.

docs/032_thematic_mapping_geom_sf.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,12 +2115,11 @@ <h1>Thematic Mapping with geom_sf</h1>
21152115
<div class="d-article">
21162116
<div class="layout-chunk" data-layout="l-body">
21172117
<div class="sourceCode">
2118-
<pre class="sourceCode r"><code class="sourceCode r"><span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://tidyverse.tidyverse.org'>tidyverse</a></span><span class='op'>)</span> <span class='co'># Tidyverse for Tidy Data</span>
2118+
<pre class="sourceCode r"><code class="sourceCode r"><span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://tidyverse.tidyverse.org'>tidyverse</a></span><span class='op'>)</span>
21192119
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://readxl.tidyverse.org'>readxl</a></span><span class='op'>)</span>
21202120
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://github.com/walkerke/tigris'>tigris</a></span><span class='op'>)</span>
21212121
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://r-spatial.github.io/sf/'>sf</a></span><span class='op'>)</span>
21222122
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://sjmgarnier.github.io/viridis/'>viridis</a></span><span class='op'>)</span>
2123-
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://ggplot2.tidyverse.org'>ggplot2</a></span><span class='op'>)</span>
21242123
</code></pre>
21252124
</div>
21262125
</div>
@@ -2192,17 +2191,18 @@ <h2 id="ggplot2-with-geom_sf-and-viridis">ggplot2 with geom_sf and viridis</h2>
21922191
<p>In this plot I <strong>reversed</strong> the <em>direction</em> of the color scale. Reversing the color pallette’s direction is not a visualization best practice, but I use this approach to demonstrate the <code>direction</code> argument.</p>
21932192
<p>Use a pleasing projection. In this case assign the CRS projection to ‘5070’</p>
21942193
<blockquote>
2195-
<p><code>coord_sf(crs = 5070)</code>  Help with <a href="https://guides.library.duke.edu/r-geospatial/CRS">projection/CRS</a> <code>coords_sf(datum = NA)</code> Remove gridlines, i.e <a href="https://en.wikipedia.org/wiki/Graticule">graticules</a></p>
2194+
<p><code>coord_sf(crs = 5070)</code>  Help with <a href="https://guides.library.duke.edu/r-geospatial/CRS">projection/CRS</a><br />
2195+
<code>coords_sf(datum = NA)</code> Remove gridlines, i.e <a href="https://en.wikipedia.org/wiki/Graticule">graticules</a></p>
21962196
</blockquote>
21972197
<div class="layout-chunk" data-layout="l-body">
21982198
<div class="sourceCode">
21992199
<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>contiguous_states</span> <span class='op'>%&gt;%</span>
2200-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span><span class='op'>(</span><span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><span class='op'>(</span>fill <span class='op'>=</span> <span class='va'>wages</span>, color <span class='op'>=</span> <span class='va'>wages</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>+</span>
2201-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggsf.html'>geom_sf</a></span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2202-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggsf.html'>coord_sf</a></span><span class='op'>(</span>crs <span class='op'>=</span> <span class='fl'>5070</span>, datum <span class='op'>=</span> <span class='cn'>NA</span><span class='op'>)</span> <span class='op'>+</span>
2200+
<span class='fu'>ggplot</span><span class='op'>(</span><span class='fu'>aes</span><span class='op'>(</span>fill <span class='op'>=</span> <span class='va'>wages</span>, color <span class='op'>=</span> <span class='va'>wages</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>+</span>
2201+
<span class='fu'>geom_sf</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2202+
<span class='fu'>coord_sf</span><span class='op'>(</span>crs <span class='op'>=</span> <span class='fl'>5070</span>, datum <span class='op'>=</span> <span class='cn'>NA</span><span class='op'>)</span> <span class='op'>+</span>
22032203
<span class='fu'><a href='https://sjmgarnier.github.io/viridis/reference/scale_viridis.html'>scale_fill_viridis</a></span><span class='op'>(</span>direction <span class='op'>=</span> <span class='op'>-</span><span class='fl'>1</span>, label <span class='op'>=</span> <span class='fu'>scales</span><span class='fu'>::</span><span class='va'><a href='https://scales.r-lib.org/reference/label_dollar.html'>dollar</a></span><span class='op'>)</span> <span class='op'>+</span>
22042204
<span class='fu'><a href='https://sjmgarnier.github.io/viridis/reference/scale_viridis.html'>scale_color_viridis</a></span><span class='op'>(</span>direction <span class='op'>=</span> <span class='op'>-</span><span class='fl'>1</span>, label <span class='op'>=</span> <span class='fu'>scales</span><span class='fu'>::</span><span class='va'><a href='https://scales.r-lib.org/reference/label_dollar.html'>dollar</a></span><span class='op'>)</span> <span class='op'>+</span>
2205-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span><span class='op'>(</span>title <span class='op'>=</span> <span class='st'>"Annual Mean Wages by State"</span>,
2205+
<span class='fu'>labs</span><span class='op'>(</span>title <span class='op'>=</span> <span class='st'>"Annual Mean Wages by State"</span>,
22062206
subtitle <span class='op'>=</span> <span class='st'>"Mental Health and Substance Abuse Social Workers(SOC Code211023)"</span>,
22072207
caption <span class='op'>=</span> <span class='st'>"Data Source: BLS.gov - Occupational Employment Statistics ; 2016"</span><span class='op'>)</span>
22082208
</code></pre>

docs/038_facets_wrap_thematic_mapping.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,12 +2289,12 @@ <h3 id="display-map">Display Map</h3>
22892289
<div class="layout-chunk" data-layout="l-body">
22902290
<div class="sourceCode">
22912291
<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>my_df</span> <span class='op'>%&gt;%</span>
2292-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span><span class='op'>(</span><span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><span class='op'>(</span>fill <span class='op'>=</span> <span class='va'>wages</span>, color <span class='op'>=</span> <span class='va'>wages</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>+</span>
2293-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggsf.html'>geom_sf</a></span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2294-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggsf.html'>coord_sf</a></span><span class='op'>(</span>crs <span class='op'>=</span> <span class='fl'>5070</span>, datum <span class='op'>=</span> <span class='cn'>NA</span><span class='op'>)</span> <span class='op'>+</span>
2295-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_c</a></span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2296-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_color_viridis_c</a></span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2297-
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/facet_wrap.html'>facet_wrap</a></span><span class='op'>(</span><span class='op'>~</span> <span class='va'>category</span>,
2292+
<span class='fu'>ggplot</span><span class='op'>(</span><span class='fu'>aes</span><span class='op'>(</span>fill <span class='op'>=</span> <span class='va'>wages</span>, color <span class='op'>=</span> <span class='va'>wages</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>+</span>
2293+
<span class='fu'>geom_sf</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2294+
<span class='fu'>coord_sf</span><span class='op'>(</span>crs <span class='op'>=</span> <span class='fl'>5070</span>, datum <span class='op'>=</span> <span class='cn'>NA</span><span class='op'>)</span> <span class='op'>+</span>
2295+
<span class='fu'>scale_fill_viridis_c</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2296+
<span class='fu'>scale_color_viridis_c</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
2297+
<span class='fu'>facet_wrap</span><span class='op'>(</span><span class='op'>~</span> <span class='va'>category</span>,
22982298
nrow <span class='op'>=</span> <span class='fl'>3</span>, ncol <span class='op'>=</span> <span class='fl'>2</span><span class='op'>)</span>
22992299
</code></pre>
23002300
</div>
@@ -2303,7 +2303,7 @@ <h3 id="display-map">Display Map</h3>
23032303
<h3 id="save-map">Save Map</h3>
23042304
<div class="layout-chunk" data-layout="l-body">
23052305
<div class="sourceCode">
2306-
<pre class="sourceCode r"><code class="sourceCode r"><span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggsave.html'>ggsave</a></span><span class='op'>(</span><span class='st'>"facet_map.png"</span>, width <span class='op'>=</span> <span class='fl'>8</span>, height <span class='op'>=</span> <span class='fl'>8</span>, units <span class='op'>=</span> <span class='st'>"in"</span><span class='op'>)</span>
2306+
<pre class="sourceCode r"><code class="sourceCode r"><span class='fu'>ggsave</span><span class='op'>(</span><span class='st'>"facet_map.png"</span>, width <span class='op'>=</span> <span class='fl'>8</span>, height <span class='op'>=</span> <span class='fl'>8</span>, units <span class='op'>=</span> <span class='st'>"in"</span><span class='op'>)</span>
23072307
</code></pre>
23082308
</div>
23092309
</div>
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)