Skip to content

Commit 76c8a03

Browse files
committed
rebuild website & update pages
1 parent 6445672 commit 76c8a03

32 files changed

+141
-170
lines changed

01_ggmap_georef.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ output: html_document
66
---
77
 
88

9-
This page is deprecated. The `mapview` packages seems to do much of the same thing, and with less effort. Explore our introduction to the [plotting coordinates with mapview](01_georeference.html).
9+
> This page is **deprecated**. The `mapview` packages deliveres much of the same functionality, and with less effort. Please explore the introduction to the [plotting coordinates with mapview](01_georeference.html).
1010
1111
Using the same data as in the [previous exercise](01_georeference.html), **build a static map quickly and easily using `ggmap`**. The `ggmap` package enables the integration of popular raster base-maps with ggplot2 syntax.
1212

030_thematic_sf.Rmd

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,31 @@ output: html_document
1010

1111
1. Thematic Mapping with [sf & ggplot::geom_sf](032_thematic_mapping_geom_sf.html): creating choropleth with `ggplot2`, `sf`, and `viridis` packages
1212

13-
1. [Interactive thematic mapping](033_thematic_leaflet_example.html) with leaflet. This is largely a repeat of the Choropleth section (tidyverse), but focused on other interactive and stylistics features not previously discussed.
14-
15-
1. [Sharing ouput files](036_thematic_mapping-outputs-fullwebpage.html): saving maps.
16-
1713
1. [Faceted Thematic Maps](039_facet_example.html) with **ggplot2::geom_sf**
1814

15+
1. [Saving ouput files](01_georeference.html#save_the_map).
16+
1917
## Simple Features
2018

21-
The initial modules of *Mapping in R* introduce plotting latitude and longitude with an interactive map (`leaflet`), a static map (`ggmap`), and generating a thematic map using `tidycensus.` The focus of this module is to introduce other customized thematic map packages: `tmap`, `sf`, `ggplot2`.
19+
The initial modules of *Mapping in R* introduce plotting latitude and longitude with an interactive map (`mapview`) and generating a choropleth (a thematic map) using `tidycensus.` The focus of this module is to introduce other customized thematic map packages: `tmap`, `sf`, `ggplot2`.
2220

23-
**The backbone of this type of mapping data manipulation is the `sf` package** -- sf for simple features -- a modern tidyverse compatible package for encoding spatial vector data. `sf` is the successor to `sp`. Since `sf` is tidyverse compatible, among the advantages is the fact that you can see your numeric data in a more familiar (and easier-to-view) data frame .
21+
**The backbone of this type of mapping data manipulation is the [`sf` package](https://r-spatial.github.io/sf/)** -- sf for simple features -- a modern tidyverse compatible package for encoding spatial vector data. `sf` is the successor to `sp`. Since `sf` is tidyverse compatible, among the advantages is the fact that you can see your numeric data in a more familiar (and easier-to-view) data frame .
2422

2523
> The `sf` simple features package affords the R coder an easy and familiar method of **storing data** vectors and **shapefile** polygons in a **tidy data frame**.
2624
27-
In these *Thematic Mapping with Simple Features* sections, we introduce the `tmap` package first. Through the the `tmap` package you will learn an easy-to-use package for building spatial distributions on geographic maps. These maps are typically `.png` image files. (.png files are easy to produce and share.) In this section we'll also use the `tigris` package -- to gather Census shapefiles -- and store those shape objects as in the Simple Features data structure. (In the [*Chropleth* module](02_choropleth.html) we used `tidycensus` to gather census Geography shape objects, as well as to gather census data variables.) `tigris` simply gathers the shapefile polygons. Later we will join the polygon object to a data frame using `tmaptools`.
25+
In these *Thematic Mapping with Simple Features* sections, we introduce the `tmap` package first. Through the the `tmap` package you will learn an easy-to-use package for building spatial distributions on geographic maps. These maps are typically `.png` image files. (.png files are easy to produce and share.) In this section we'll also use the `tigris` package -- to gather Census shapefiles -- and store those shape objects in the Simple Features data structure. (In the [*Chropleth* module](02_choropleth.html) we used `tidycensus` to gather census Geography shape objects, as well as to gather census data variables.) `tigris` simply gathers the shapefile polygons. Later we will join the polygon object to a data frame using `tmaptools`.
2826

2927
Next, we'll use the `ggplot::geom_sf` function to create our mapping visualiations using the widely adopted ggplot2 syntax.
3028

3129
Later, in the *interactive thematic mapping* section, you will make a different interactive choropleth using `leaflet`. This section is largely a repeat of the earlier choropleth module. The level of interactivity is sparse, but functional. Interactivity demonstrates how you can generate maps which move beyond traditional 2D map-on-a-page images. Just know that this zoom-in/zoom-out interactivity feature is possible because we use `leaflet` to draw the map. By extension, you can add many interactive features, e.g. pop-up windows. This section is a good set-up for the last section which covers how to save maps as files.
3230

33-
[Sharing ouput files](036_thematic_mapping-outputs-fullwebpage.html), introduces the file saving techniques for saving maps. Even interactive maps can be shared and distributed. You can share maps either on the web, as an HTML file, or as [shapefile.](next.html#shapefiles)
31+
[Saving / sharing ouput files](01_georeference.html#save_the_map). Even interactive maps can be shared and distributed. You can share maps either on the web, as an HTML file.
3432

3533

3634
## Converting between `sf` and `sp`
3735

3836
`sf` is developed by the same [person](https://github.com/edzer)/people who developed `sp`. `sf` is the modern approach. However, if you need to convert between the two formats, it's easy! See [Reading, Writing and Converting Simple Features](https://r-spatial.github.io/sf/articles/sf2.html)
3937

4038

41-
## Hands-on Exercises
4239

43-
Head over to the [exercises section](exercises.html) and practice making your own thematic map.
4440

031_thematic_mapping.Rmd

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ library(sf)
1616

1717
## Shapefiles as sf
1818

19-
Using the `tigris` package, get Census Tiger shapefiles for census geographies. Tigris will return the shapefile in the `sf`, or simple features, format. (See also, [more information on Shapefiles](02_choropleth.html#shapefiles).)
19+
Using the `tigris` package, get Census Tiger shapefiles for census geographies. Tigris will return the shapefile in the `sf`, or simple features, format.
2020

2121
```{}
2222
us_geo <- tigris::states(class = "sf")
23-
# us_geo_spdf <- states() # spdf uses @data slots -- old school
2423
```
2524

2625
```{r get-data, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
@@ -30,7 +29,7 @@ us_geo <- tigris::states(class = "sf")
3029

3130
## Data Structure
3231

33-
The advantage of managing your spatial data as "Simple Features" (i.e. sf) over `sp` is that `sf` data can easily be viewed and manipulated as a rectangular data frame, before visualizing. `sp` is the predecessor to `sf`, but uses the old school @data slots method. If you're used to this it can be a highly functional data structure. But if you're inclined toward the tidyverse method, you'll see your data in a more familiar and easy-to-view format. Below are two methods of viewing the structure of the downloaded shapefiles.
32+
The "Simple Features" (`sf`) data structure can easily be viewed and manipulated as a rectangular data frame, before visualizing. As an historical note -- an `sf` predecessor -- the `sp` data structure uses `@data` slots to hold data. We'll focus on the `sf` package. Below are two methods of viewing the structure of the downloaded shapefiles.
3433

3534
```{r data-structure}
3635
class(us_geo)
@@ -46,6 +45,18 @@ And as noted, here's the data frame view. Notice the geometry (polygon shape) i
4645
as_tibble(us_geo)
4746
```
4847

48+
### Quick Plotting
49+
50+
If you want to see a very quick view of your mapping data, you can plot the geometry data with the `plot` function. In this case we use the `sf::st_geometry()` function to plot only the geometry. You can quickly generate a faceted map by excluding the `st_geometry` function: e.g. `plot(us_geo)` but that will consume computation cycles (i.e. wait time). Therefore, I recommend trying the smaller layer for now.
51+
52+
> **Note:** Census geography for the USA will span the globe in part becuase Region 9 includes a multitude of pacific islands. Later we will limit to simply the "lower 48" states.
53+
54+
```{r}
55+
plot(st_geometry(us_geo))
56+
```
57+
58+
59+
4960
## Get BLS data
5061

5162
I've already downloaded and stored some data from the Bureau of Labor Statistics. Those data are stored in an excel file in the `data` directory of the [repository](https://github.com/libjohn/mapping-with-R): `data/OES_Report.xlsx`. **The goal is to attach this data to the previously downloaded shapefiles.**
@@ -147,7 +158,7 @@ Mark likes the USA_Contiguous_Albers_Equal_Area_Conic_USGS_version projection fo
147158
contiguous_states %>%
148159
st_transform(5070) %>%
149160
tm_shape() +
150-
tm_polygons("wages", id = "Name")
161+
tm_polygons("wages", id = "Name")
151162
```
152163

153164

032_thematic_mapping_geom_sf.Rmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,15 @@ contiguous_states %>%
9090

9191
## ggplot2 with geom_sf and viridis
9292

93-
In this section we introduce making shapefiles with ggplot2. ggplot2 is one of the more popular and broadly distributed graphics packages used in the R community. I also reveresed the direction of the color scale. After consulting with my visualization colleagues it seems this may have been a non-standard action on my part. But I leave the `direction` argument here for the curious.
93+
In this section we introduce making shapefiles with ggplot2. ggplot2 is one of the more popular and broadly distributed graphics packages used in the R community. I also reversed the direction of the color scale. After consulting with my visualization colleagues it seems this may have been a non-standard action on my part. But, I leave the `direction` argument here for the curious. Finally, please note the easiest way to remove the [graticules](https://en.wikipedia.org/wiki/Graticule) is as follows: `coords_sf(datum = NA)`
9494

9595
```{r with-ggplot-geom_sf}
9696
contiguous_states %>%
9797
ggplot(aes(fill = wages, color = wages)) +
9898
geom_sf() +
99-
coord_sf(crs = 5070) +
99+
coord_sf(crs = 5070, datum = NA) +
100100
scale_fill_viridis(option = "viridis", direction = -1) +
101101
scale_color_viridis(option = "viridis", direction = -1)
102-
103-
104102
```
105103

106104

033_thematic_leaflet_example.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ output:
55
toc: FALSE
66
---
77

8+
> This page is **deprecated**. The `mapview` packages deliveres much of the same functionality, and with less effort. Please explore the introduction to the [plotting coordinates with mapview](01_georeference.html).
9+
10+
811
```{r}
912
library(leaflet)
1013
```

036_thematic_mapping-outputs-fullwebpage.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Thematic Mapping: Saving Ouput Files"
33
output: html_document
44
---
55

6+
7+
> This page is **deprecated**. The `mapview` packages deliveres much of the same functionality, and with less effort. Please explore the introduction to the [saving maps with mapview](01_georeference.html#save_the_map).
8+
69
On this page we demonstrate two methods of saving map files for sharing. The first method develops an interactive map that uses the entire web browser as the delivery mechanism. It's a nice way to maximize screen estate, a desirable feature for maps. The second method saves the file as a **shapefile**, a broadly portable file standard in GIS analysis.
710

811
Please note that I disabled some of the code chunks for efficiency of processing. The process documented below does work, despite reported feedback errors: [See the example output](mymap_sasw.html). This method should work for you as well, all the code is below. If you download this file from the repository, you'll need to make a simple change to the last two code chunks: re-insert the `r` into the curley braces in the last two code chunks.

038_facets_wrap_thematic_mapping.Rmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,3 @@ tall %>%
342342
```{r save_it}
343343
ggsave("facet_map.png", width = 8, height = 8, units = "in")
344344
```
345-

039_facet_example.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Produced this faceted map
2323

2424
![](facet_map.png)
2525

26-
Full disclosure. The actual code was produced on the garbage-spaghetti plan. The quality of the code is not something I'm proud of. Therefore, I sanitized the code by showing the example, above. All the [actual code is available](038_facets_wrap_thematic_mapping.html). You can explore and/or reproduce this process from the actual code, as you see fit. If you don't mind, rewrite the code, using `purrr` then send me a cleaned and literate version. 'prec.
26+
Full disclosure. The actual code was produced on the garbage-spaghetti plan. The quality of the code is not something I'm proud of. Therefore, I sanitized the code by showing the example, above. All the [actual code is available](038_facets_wrap_thematic_mapping.html). You can explore and/or reproduce this process from the actual code, as you see fit. (If you don't mind, rewrite the code, using `purrr` then send me a cleaned and literate version.)

_site.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ navbar:
2828
href: 032_thematic_mapping_geom_sf.html
2929
- text: "ggplot2 & facet mapping"
3030
href: 039_facet_example.html
31-
- text: "Interactive"
32-
href: 033_thematic_leaflet_example.html
3331
- text: "Saving / Sharing"
34-
href: 036_thematic_mapping-outputs-fullwebpage.html
32+
href: 01_georeference.html#save_the_map
3533
- text: Exercises
3634
href: exercises.html
3735
right:

docs/01_georeference.html

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

0 commit comments

Comments
 (0)