class: left, middle, inverse background-image: url("https://live.staticflickr.com/65535/50362989122_a8ee154fea_k_d.jpg") background-size: cover # .green[Cartography] ### .fancy[The Art or Technique of Making Maps <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="rfa" style="height:0.75em;fill:limegreen;position:relative;"><path d="M0 117.66v346.32c0 11.32 11.43 19.06 21.94 14.86L160 416V32L20.12 87.95A32.006 32.006 0 0 0 0 117.66zM192 416l192 64V96L192 32v384zM554.06 33.16L416 96v384l139.88-55.95A31.996 31.996 0 0 0 576 394.34V48.02c0-11.32-11.43-19.06-21.94-14.86z"/></svg>] --- # Factors that affect design .pull-left[ .red[- Objective - Audience - Reality and generalization - Map scale - Technical limits] ] .pull-right[ ![](https://live.staticflickr.com/65535/51021699777_928b6fd4c5_o.png)] --- # Basic elements of a Map .pull-left[.red[- Title - Legend - Scale - North arrow - Additional information]] .pull-right[ ![](https://live.staticflickr.com/65535/51021699777_928b6fd4c5_o.png)] --- # Effective Maps .pull-left[.red[- Communicates a clear message - Appropriate projection - Data at appropriate level of generalization - Clear symbology ]] .pull-right[ ![](https://live.staticflickr.com/65535/51021699777_928b6fd4c5_o.png) ] --- class: sectionTitle, inverse # .green[Common Types of Maps] --- .left[.red[Dot Density] ] .left-column[ <p> </p> <p> </p> <p> </p> - Spatial distribution and quantity] .right[ ![](https://live.staticflickr.com/65535/51021633697_3c0b753abc_z.jpg)] --- .red[Proportional Symbols] .left[ - Size of symbols is related to the value of phenomenon represented] .right[ ![](https://live.staticflickr.com/65535/51020804313_b88b158267_b.jpg) ] --- .red[Choropleth] <p> </p> .top[ - Data is colored or shaded base on an attribute] <p> </p> .center[ ![](https://live.staticflickr.com/65535/51021633662_7c8cdcd623_b.jpg)] --- .red[Isoline] .pull-left[ <p> </p> - Lines connect points knows or estimated to have equal vales - Used in maps of temperature, precipitation, air pressure, climate classifications, ect - Topographic maps: type of isoline map depicting elevation] .pull-right[ ![](https://live.staticflickr.com/65535/51021531891_7a2ba3767e_b.jpg)] --- class: sectionTitle, inverse # .green[Map Making] --- .red[Basic Plotting] .left-column[ <p> </p> ####Packages: `ggplot` `naturalearth` `naturalearthdata` ] .right-column[ ```r ggplot(world) + geom_sf() ``` ![](https://live.staticflickr.com/65535/51021633622_e25253c196_b.jpg) ] --- .red[Add Title, Subtitle, Axes Labels] .center[ ![](https://live.staticflickr.com/65535/51021633627_87a9a86d0b_z.jpg) ] .bottom[ ```r p + xlab("Longitude") + ylab("Latitude") + ggtitle("World Map", subtitle = paste0("(" ,length(unique(world$name)), "countries)" )) ``` ] --- .red[Color Palettes] .top[ ```r p + geom_sf(aes(fill = pop_est)) + scale_fill_viridis_c( trans = "sqrt") ``` ] .center[ ![](https://live.staticflickr.com/65535/51020804303_d77450ab68_c.jpg) ] --- .red[Scale Bar & North Arrow] .pull-left[ `library(ggspatial)` ```r p+ annotation_scale(location = "br", style = "bar") + annotation_north_arrow(location = "br", width = unit(.5, "cm"), height = unit(.75, "cm"), pad_y = unit(0.75, "cm"), pad_x = unit(0.5, "cm"), style = north_arrow_orienteering( text_size = 8 )) ``` ] .pull-right[ ![](https://live.staticflickr.com/65535/51021633642_b3a4c5c2c5_b.jpg)] --- .red[Adding Names & Labels] .pull-left[ .green[`library(ggrepel)`] ```r + geom_text_repel(data= my_points, aes(x=X, y=Y, label=name), color = "royalblue4", fontface = "bold", size = 3.5, point.padding = 0, box.padding = unit(.5, "cm")) ``` ] .pull-right[ ![](https://live.staticflickr.com/65535/51020804198_06087d7679_b.jpg) ] --- .red[Annotate] .push-right[ ```r + annotate(geom = "text",x = -90, y = 26, label = "Gulf of Mexico", fontface = "italic", color = "grey22", size = 4) ``` ] .center[ ![](https://live.staticflickr.com/65535/51020804288_f1f8f3f623.jpg)] --- class: sectionTitle, inverse # .green[Layouts] --- .red[Side by side] .green[`library(cowplot)`] ```r plot_grid(world_map, Mexico, nrow = 1, rel_widths = c(2.3, 1)) ``` .right[ ![](https://live.staticflickr.com/65535/51021531841_e233e75ed5_b.jpg)] --- .red[Inset Maps] .pull-left[`VA_map` ![](https://live.staticflickr.com/65535/51021531936_d8f9753a8e_b.jpg) ] -- .pull-right[`RVA_map` ![](https://live.staticflickr.com/65535/51020804333_8441117c50_b.jpg) ] --- .red[Inset Maps] ```r ggdraw(VA_map) + draw_plot(RVA_map,width = 0.25, height = 0.25* 10/4 * ratioRVA, x = .15, y = .5) ``` ![](https://live.staticflickr.com/65535/51020804223_abbdb227a0_b.jpg) --- .red[Now with Arrows!] ```r arrowA <- data.frame(x1 = 18, x2 = 25, y1 = 3.45, y2 = 3.55) ``` ```r ggdraw(xlim = c(0, 35), ylim = c(0, 7.5)) + draw_plot(VA_map, x = 0, y = 0, width = 25, height = 7.5) + draw_plot(RVA_map, x = 24, y = .5, width = 10, height = 7)+ geom_segment(aes(x = x1, y = y1, xend = x2, yend = y2), data = arrowA, arrow = arrow(), lineend = "round") ``` --- .center[ ![](https://live.staticflickr.com/65535/51021533596_df37bc5cee_c.jpg)] --- .blue[Resources] .pull-left[ [Drawing maps in ggplot2](https://www.r-spatial.org/r/2018/10/25/ggplot2-sf.html) ![](https://live.staticflickr.com/65535/51022629192_4d62718ced_o.jpg) <p> </p> --- <p> </p> [ggplot2 cheat sheet](https://rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf) ![](https://live.staticflickr.com/65535/51022531071_d532cf2aab_o.jpg)] .pull-right[ [Making maps in R](https://geocompr.robinlovelace.net/adv-map.html) ![](https://live.staticflickr.com/65535/51022763791_5f44f6df33_o.jpg) --- [cowplot package](https://wilkelab.org/cowplot/articles/index.html) ![](https://live.staticflickr.com/65535/51022067998_9325be84f3_m.jpg) ] https://github.com/dyerlab/ENVS-Lectures/blob/1809f76b91c434f84f416bce7cd3aaf7033c2996/data/DEM_5m.tif --- class: middle background-image: url("images/contour.png") background-position: right background-size: auto .center[ .red[Questions?] ![Dog](https://i.redd.it/opy67ug150541.jpg) ] <p> </p> .bottom[ If you have any questions for about the content presented herein, please feel free to [submit them to me](mailto://deadwylerm@vcu.edu) and I'll get back to you as soon as possible.]