A Globe And A Flat Map
5 Map Projections
Map projections exist because we are trying to take the round globe of the earth, and project it onto a 2 dimensional surface. Because a spherical globe can not be projected onto a flat surface without some distortion, different projections make different choices about the kind of distortion involved.
This chapter is mostly a conceptual overview, and not code-focused. However, the code is provided for the sake of transparency and teaching. It is not necessary to understand the code here. But I learned a lot from: https://plotly.com/r/#maps.
5.1 Set Up The Map
5.2 Call plotly
Library
Show the code
library(plotly)
5.3 A Basic Map
Show the code
# a very basic map could be created with:
library(plotly)
<- plot_geo() # create basic map; read into mymap0
mymap0
# replay mymap0
5.4 A More Advanced Map
Again, it is not necessary to understand the code to understand the conceptual ideas of this chapter. The code below–especially the first code chunk–is admittedly a little complicated, mostly because I added options to get the map to look exactly the way that I wanted.
Show the code
<- plot_geo() %>%
mymap layout(title = "Demonstration Map",
geo = list(showland = TRUE, # show land
landcolor = toRGB("darkgrey"), # land color
showcountries = TRUE, # show countries
showocean = FALSE, # show ocean
oceancolor = "lightblue", # ocean color
lataxis = list(showgrid = TRUE, # latitude options
gridcolor = toRGB("grey")),
lonaxis = list(showgrid = TRUE, # longitude options
gridcolor = toRGB("grey"))))
# replay mymap
5.5 Map Projections
5.5.1 Globe (Orthographic)
An orthographic projection reprsents the globe with 3 dimensional accuracy.
Show the code
%>%
mymap layout(geo = list(projection = list(type = 'orthographic')))
5.5.2 Mercator
A Mercator projection reprsents the earth with perpendicular latitude and longitude. This projection can be helpful in some kinds of navigation, but areas of landmasses are distorted, especially as one approaches the poles.
Show the code
%>%
mymap layout(geo=list(projection = list(type = 'mercator')))
5.5.3 Mollweide
The Mollweide projection is an equal area projection. As a consequence, latitude and longitude lines are not perpendicular, and the shapes of some landmasses may appear to be distorted.
Show the code
%>%
mymap layout(geo=list(projection = list(type = 'mollweide')))
5.5.4 Robinson
The Robinson projection is an attempt to compromise between equal areas and a natural looking map.
Show the code
%>%
mymap layout(geo=list(projection = list(type = 'robinson')))