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
@@ -24,7 +24,7 @@ The initial modules of *Mapping in R* introduce plotting latitude and longitude
24
24
25
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`.
26
26
27
-
Next, we'll use the `ggplot::geom_sf` function to create our mapping visualiations using the widely adopted ggplot2 syntax.
27
+
Next, we'll use the `ggplot::geom_sf` function to create our mapping visualizations using the widely adopted ggplot2 syntax.
28
28
29
29
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.
Copy file name to clipboardExpand all lines: 032_thematic_mapping_geom_sf.Rmd
+27-30Lines changed: 27 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,13 @@ library(ggplot2)
16
16
17
17
## Shapefiles as sf
18
18
19
-
Repeating steps from the [previous section](031_thematic_mapping.html), using the `tigris` package, get Census Tiger shapefiles for census geographies.
19
+
Repeating steps from the [previous section](031_thematic_mapping.html), using the `tigris` package, get Census Tiger shapefiles for census geographies. Coastal boundaries can be gathered with the tigris argument: `cb = TRUE`.
Using the USA_Contiguous_Albers_Equal_Area_Conic_USGS_version projection for the continental US. `EPSG:5070`
82
-
83
-
```{}
84
-
contiguous_states %>%
85
-
st_transform(5070) %>%
86
-
tm_shape() +
87
-
tm_polygons("wages", id = "Name")
88
-
```
80
+
## ggplot2 with geom_sf and viridis
89
81
82
+
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. ([Learn more](https://rfun.library.duke.edu/#portfolio) about ggplot2.
90
83
91
-
## ggplot2 with geom_sf and viridis
84
+
In this plot I 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.
92
85
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)`
86
+
Use a pleasing projection, in this case assigned the crs projection to '5070' (`coord_sf(crs = 5070)`), and removed the gridlines (i.e [graticules](https://en.wikipedia.org/wiki/Graticule))`coords_sf(datum = NA)`
0 commit comments