Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section 16.2.3 Out of Date, w/ broken-looking maps #363

Open
jack-davison opened this issue Apr 27, 2023 · 0 comments
Open

Section 16.2.3 Out of Date, w/ broken-looking maps #363

jack-davison opened this issue Apr 27, 2023 · 0 comments

Comments

@jack-davison
Copy link

jack-davison commented Apr 27, 2023

Good afternoon, and thank you for all your work with {ggplot2} and the ggplot2 book.

I was going to refer someone to Chapter 16 of the ggplot2 book and noted that section 16.2.3 seems out of date, with some broken appearing maps.

Outdated info?

Maps are intrinsically displays of spherical data. Simply plotting raw longitudes and latitudes is misleading, so we must project the data. There are two ways to do this with ggplot2:

Nowadays there are three ways to do this in {ggplot2} w/ coord_sf(), so should this read three ways? Further, coord_map() and coord_quickmap() are superseded - a blog on RStudio Education suggested not teaching superseded functions. I appreciate this may be personal opinion for the author, but it may be useful for readers to know how to recreate the visualisations below using coord_sf().

Broken-looking graphics

At the bottom of this page, there are a couple of broken looking maps:

  1. On the left hand side, the world map has a load of bands cutting across the center of it.
  2. The far right plot looks like a little splodge rather than an actual map.

image

Pulling together

May it be appropriate to focus on coord_sf() in section 16.2.3 and make more passing mention to coord_map()/coord_quickmap()? Or at least provide more direct guidance on the recommended coordinate system for map coordinates, as some may be put off by the "superseded" label on coord_map() but have no idea how to properly use coord_sf().

library(ggplot2)
library(patchwork)

world <- map_data("world")
worldmap <- ggplot(world, aes(long, lat, group = group)) +
  geom_path() +
  theme_minimal()

latlng <- worldmap + coord_sf(default_crs = 4326)

# Some crazier projections
ortho <- worldmap +
  coord_sf(default_crs = 4326, 
           crs = "+proj=ortho")

stereo <- worldmap +
  coord_sf(default_crs = 4326, crs = 3995) +
  scale_y_continuous(limits = c(-40, 40))

latlng + ortho + stereo
#> Warning: Removed 49207 rows containing missing values (`geom_path()`).

Created on 2023-04-27 with reprex v2.0.2

Thanks again,
Jack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant