0

I have a map of the US county boundaries. The small section of Alaska that falls in the Eastern Hemisphere is showed at the right of the map, distorting the plot. I would like to explore options to re-center the map without losing that section.

I downloaded the US county (year: 2021, scale: 1:500k) boundaries shapefile from the US Census website, loaded in R using st_read(), and excluded all territories.

library(ggplot2); library(st)

shp = st_read(dsn = "cb_2021_us_county_500k/cb_2021_us_county_500k.shp")
shps_sf = shp[!(shp$STUSPS %in% c("PR","AS","GU","MP","VI")),]

ggplot()+ 
  geom_sf(data=shps_sf) #+coord_sf(xlim=c(-175,-70))

output

As the image shows, a small part of Alaska is plotted in the right side of the graph, consistent with its coordinates but distorting the graph. If I use coord_sf() I can crop the graph and re-center the map. However, I would rather not lose that area.

Is there a way to manipulate the x-axis (or other features of the plot) to re-center the map without losing that section from Alaska?

I know there are options like usmap::plot_usmap() or tidycensus::county_laea that take care of this issue by shifting and re-scaling Alaska, but I have another layer of points that wouldn't work with those options, so I'd prefer not to go that route.

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
  • Sounds like this is a use case for the `st_shift_longitude()` function from the sf package. Perhaps start with applying that to your shapefile & a coord range in the region of `coord_sf(xlim=c(170, 300))`? – Z.Lin Apr 28 '23 at 01:49
  • Separately, I think you might have meant to load `package(sf)` instead of `package(st)` in your example. For confirmation pls. – Z.Lin Apr 28 '23 at 01:50

0 Answers0