+ - 0:00:00
Notes for current slide
Notes for next slide

Working with Geospatial Data

Projections

Ben Baumer

SDS 192
April 10th, 2020
(http://beanumber.github.io/sds192/lectures/mdsr_geo_06-projections.html)

1 / 16

Projections

2 / 16
3 / 16

Principles

https://en.wikipedia.org/wiki/Map_projection

"All projections of a sphere on a plane necessarily distort the surface in some way and to some extent."

4 / 16

Principles

https://en.wikipedia.org/wiki/Map_projection

"All projections of a sphere on a plane necessarily distort the surface in some way and to some extent."

  • Properties:
    • Area
    • Shape
    • Direction
    • Bearing
    • Distance
4 / 16

Principles

https://en.wikipedia.org/wiki/Map_projection

"All projections of a sphere on a plane necessarily distort the surface in some way and to some extent."

  • Properties:
    • Area
    • Shape
    • Direction
    • Bearing
    • Distance
  • Every projection represents a trade-off in accuracy among these proporties
4 / 16

Distortion

5 / 16

Projections

6 / 16

Projections

6 / 16

Projections

Important!!: Not OK to pretend like projections don't matter

6 / 16

Mercator (preserves angles)

7 / 16

PROJ.4 strings and EPSG

library(sf)
library(macleish)
# GPS, Google Earth, Leaflet
st_crs(4326)
## Coordinate Reference System:
## User input: EPSG:4326
## wkt:
## GEOGCS["WGS 84",
## DATUM["WGS_1984",
## SPHEROID["WGS 84",6378137,298.257223563,
## AUTHORITY["EPSG","7030"]],
## AUTHORITY["EPSG","6326"]],
## PRIMEM["Greenwich",0,
## AUTHORITY["EPSG","8901"]],
## UNIT["degree",0.0174532925199433,
## AUTHORITY["EPSG","9122"]],
## AUTHORITY["EPSG","4326"]]

https://epsg.io/4326

11 / 16

Checking projections

macleish_layers %>%
pluck("buildings") %>%
st_crs()
## Coordinate Reference System:
## User input: EPSG:4326
## wkt:
## GEOGCS["WGS 84",
## DATUM["WGS_1984",
## SPHEROID["WGS 84",6378137,298.257223563,
## AUTHORITY["EPSG","7030"]],
## AUTHORITY["EPSG","6326"]],
## PRIMEM["Greenwich",0,
## AUTHORITY["EPSG","8901"]],
## UNIT["degree",0.0174532925199433,
## AUTHORITY["EPSG","9122"]],
## AUTHORITY["EPSG","4326"]]
12 / 16

Units really matter!!

macleish_layers %>%
pluck("buildings") %>%
st_bbox()
## xmin ymin xmax ymax
## -72.68251 42.44104 -72.67923 42.44919
13 / 16

Projecting geospatial data

buildings_3857 <- macleish_layers %>%
pluck("buildings") %>%
st_transform(3857)
buildings_3857 %>%
st_bbox()
## xmin ymin xmax ymax
## -8090979 5227276 -8090614 5228505
14 / 16

Oops!

library(leaflet)
leaflet() %>%
addTiles() %>%
# No error, but puts buildings at North Pole!
addPolygons(data = buildings_3857, popup = ~name)
15 / 16

Projections checklist

  • : Are you using leaflet?
    • Project everything in EPSG 4326
16 / 16

Projections checklist

  • : Are you using leaflet?
    • Project everything in EPSG 4326
  • : Are you using ggplot2?
    • Choose a projection scheme that is appropriate for your data
    • Project everything in that scheme
16 / 16

Projections

2 / 16
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow