class: center, middle, inverse, title-slide # Lec 29: Static Maps ## SDS 192: Introduction to Data Science ###
Shiya Cao
Statistical & Data Sciences
, Smith College
###
Fall 2024
--- # Today's Learning Goals * Understand projections. * Use `sf` package for static maps in `ggplot2` and converting data frames to `sf` objects. * Load shapefiles into R. --- # Why Analyze Spatial Data? .pull-left[ * How are features distributed across geographies, and what does this tell us about potential disparities? * Where are certain events or features concentrated, and what other conditions might implicate these patterns? * What is the best way to get from point A to point B? ] .pull-right[ <img src="img./Lec30_map.jpeg" width="700" /> ] --- # Projections <iframe width="560" height="315" src="https://www.youtube.com/embed/vVX-PrBRtTY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> --- # Projections * Means by which we convert curved surface of the globe to a 2D representation. * Necessarily distorts the surface. * Properties: * Area * Shape * Direction * Bearing * Distance * Every projection represents a trade-off in accuracy among these properties. --- # [Orange Peel Example](https://esri-styles.maps.arcgis.com/home/item.html?id=bf83356620d94314b50616612a9a5a22) .pull-left[ * Imagine that you peel an orange * Datum is the original shape of the fruit (e.g. orange, lemon, apple, grapefruit). * Projection is how we go about peeling and flattening the orange. ] .pull-right[  https://geohackweek.github.io/visualization/02-projections/ ] --- #
Mercator
(preserves angles) .pull-left[ <img src="img./Lec26_1280px-Mercator_projection_Square.png" width="700" /> ] .pull-right[ By <a href="//commons.wikimedia.org/wiki/User:Strebe" title="User:Strebe">Strebe</a> - <span class="int-own-work" lang="en">Own work</span>,
CC BY-SA 3.0
,
Link
] --- #
Gall-Peters
(preserves area) <img src="img./Lec26_Gall–Peters_projection_SW.png" width="700" />
By <a href="//commons.wikimedia.org/wiki/User:Strebe" title="User:Strebe">Strebe</a> - <span class="int-own-work" lang="en">Own work</span>,
CC BY-SA 3.0
,
Link
--- #
Albers Equal Area
(preserves area) <img src="img./Lec26_Albers_projection_SW.png" width="700" />
By <a href="//commons.wikimedia.org/wiki/User:Strebe" title="User:Strebe">Strebe</a> - <span class="int-own-work" lang="en">Own work</span>,
CC BY-SA 3.0
,
Link
--- #
Lambert Conformal Conic
(preserves angles) <img src="img./Lec26_Lambert_conformal_conic_projection_SW.png" width="600" />
By <a href="//commons.wikimedia.org/wiki/User:Strebe" title="User:Strebe">Strebe</a> - <span class="int-own-work" lang="en">Own work</span>,
CC BY-SA 3.0
,
Link
--- # Coordinate Reference System (CRS) * Points are in different locations depending on how we flatten Earth's surface into 2D map. * CRS is a system for locating features on a certain map projection via coordinates. * For locations to appear correctly on maps, geographic features and underlying maps need to share same CRS. --- # Spatial Packages in R * Working with shapefiles * `sf` package for everything * Plotting * `ggplot2` for static maps * `leaflet` for interactive maps --- # Shapefiles * File for storing geospatial feature data. * Actually a series of files (.shp, .shx, and .dbf) that must **all** be present in the directory for the shapefile to import. * Imported file ends in `.shp` and contains feature geometry.