You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01_georeference.Rmd
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Latitude and Longitude Coordinates
3
3
---
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]
5
5
6
6
7
7
## Load Libraries
@@ -31,18 +31,18 @@ starbucksNC %>%
31
31
32
32
## Make the Map
33
33
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`.)
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.
@@ -2192,17 +2191,18 @@ <h2 id="ggplot2-with-geom_sf-and-viridis">ggplot2 with geom_sf and viridis</h2>
2192
2191
<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>
2193
2192
<p>Use a pleasing projection. In this case assign the CRS projection to ‘5070’</p>
2194
2193
<blockquote>
2195
-
<p><code>coord_sf(crs = 5070)</code> Help with <ahref="https://guides.library.duke.edu/r-geospatial/CRS">projection/CRS</a><code>coords_sf(datum = NA)</code> Remove gridlines, i.e <ahref="https://en.wikipedia.org/wiki/Graticule">graticules</a></p>
2194
+
<p><code>coord_sf(crs = 5070)</code> Help with <ahref="https://guides.library.duke.edu/r-geospatial/CRS">projection/CRS</a><br/>
<spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span><spanclass='op'>(</span><spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><spanclass='op'>(</span>fill <spanclass='op'>=</span><spanclass='va'>wages</span>, color <spanclass='op'>=</span><spanclass='va'>wages</span><spanclass='op'>)</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/ggsf.html'>coord_sf</a></span><spanclass='op'>(</span>crs <spanclass='op'>=</span><spanclass='fl'>5070</span>, datum <spanclass='op'>=</span><spanclass='cn'>NA</span><spanclass='op'>)</span><spanclass='op'>+</span>
2200
+
<spanclass='fu'>ggplot</span><spanclass='op'>(</span><spanclass='fu'>aes</span><spanclass='op'>(</span>fill <spanclass='op'>=</span><spanclass='va'>wages</span>, color <spanclass='op'>=</span><spanclass='va'>wages</span><spanclass='op'>)</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'>coord_sf</span><spanclass='op'>(</span>crs <spanclass='op'>=</span><spanclass='fl'>5070</span>, datum <spanclass='op'>=</span><spanclass='cn'>NA</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span><spanclass='op'>(</span>title <spanclass='op'>=</span><spanclass='st'>"Annual Mean Wages by State"</span>,
2205
+
<spanclass='fu'>labs</span><spanclass='op'>(</span>title <spanclass='op'>=</span><spanclass='st'>"Annual Mean Wages by State"</span>,
2206
2206
subtitle <spanclass='op'>=</span><spanclass='st'>"Mental Health and Substance Abuse Social Workers(SOC Code211023)"</span>,
<spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span><spanclass='op'>(</span><spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><spanclass='op'>(</span>fill <spanclass='op'>=</span><spanclass='va'>wages</span>, color <spanclass='op'>=</span><spanclass='va'>wages</span><spanclass='op'>)</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'><ahref='https://ggplot2.tidyverse.org/reference/ggsf.html'>coord_sf</a></span><spanclass='op'>(</span>crs <spanclass='op'>=</span><spanclass='fl'>5070</span>, datum <spanclass='op'>=</span><spanclass='cn'>NA</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'>ggplot</span><spanclass='op'>(</span><spanclass='fu'>aes</span><spanclass='op'>(</span>fill <spanclass='op'>=</span><spanclass='va'>wages</span>, color <spanclass='op'>=</span><spanclass='va'>wages</span><spanclass='op'>)</span><spanclass='op'>)</span><spanclass='op'>+</span>
<spanclass='fu'>coord_sf</span><spanclass='op'>(</span>crs <spanclass='op'>=</span><spanclass='fl'>5070</span>, datum <spanclass='op'>=</span><spanclass='cn'>NA</span><spanclass='op'>)</span><spanclass='op'>+</span>
0 commit comments