Open gergness opened 5 years ago
Hi Greg/Gerg, I'm interested in your issue. Have you started a repository to work on it?
library(tigris)
library(ggplot2)
library(sf)
map <- states(resolution = "20m")
map <- st_as_sf(map)
# Currently (not shifted)
ggplot(map) +
geom_sf()
# Desired syntax
ggplot(map) +
geom_sf_albersusa()
# Other possible syntaxes
ggplot(map) +
geom_sf_albersusa(
ak = ~STATEFP == 2,
hi = ~STATEFP == 5,
pr = ~STATEFP == 7
)
Data examples: https://github.com/charlesminshew/practice-datasets
For those wishing to follow along, we've started working on https://github.com/hlendway/albersextra
(It's tough to be first, hoping to spur on even better ideas!)
The
tidycensus
package has a cool feature that allows you to create maps where Alaska and Hawaii have been adjusted to fit alongside the continental US (example: https://twitter.com/kyle_e_walker/status/985889144466563072)I looked into this a bit, and found that under the hood this works by pre-building a map where the states have already been shifted and storing it in the package data. This is okay for tidycensus because the data is only related to a few shape files, but means that you can't make these kind of shifted maps with your own geographic data (eg smaller census area boundaries, congressional districts, etc.).
I think it would be possible to extend the code in
ggplot2::coord_sf()
so that the shift is applied while drawing the map, which I think would be a really elegant way for this to work. If not, perhaps there's another way to make it easier for users to shift geometries on arbitrary maps. It'd also be nice to add the ability to plot Puerto Rico, Guam and other territories and/or make similar maps for other countries.Some relevant links:
Looking back over this, I see the irony in focusing on two coastal states at the uncoast conference. But, perhaps we can have some camaraderie between being called "flyover country" vs. being left off maps altogether.