Edit: I made an embarrassing rookie mistake late at night (excuses, excuses) and flipped my lats and longs. As a result, people searching for an answer to my original question will not be helped by this. To resolve this, I've changed the title to this post to reflect the mistake caught in the accepted answer.
I'm attempting to project some data to a planar coordinate system and the results look very wrong. Here's a reproducible example with a map of New England:
library(rnaturalearth) library(sf) library(dplyr) library(ggplot2) states_sf <- ne_states(country = "united states of america", returnclass = "sf") states_names <- c("Maine", "New Hampshire", "Vermont", "Connecticut", "Rhode Island", "Massachusetts") states_sf <- filter(states_sf, name %in% states_names) ggplot(states_sf) + geom_sf() + theme_bw()
But when I project and replot the data, it doesn't look as expected.
# Lambert equal-area projection laea_centered <- "+proj=laea +lat_0=-70.30744 +lon_0=43.15268" coord_shift <- "+x_0=12019341.4 +y_0=1730136" proj_ref <- " +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" laea_proj4 <- paste(laea_centered, coord_shift, proj_ref, sep = " ") states_projected_sf <- st_transform(states_sf, crs = laea_proj4) ggplot(states_projected_sf) + geom_sf() + coord_sf(datum = st_crs(states_projected_sf)) + theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 1))
Just for grins and to further illustrate how absurdly I've managed to mangle this, here's the projected map with geographic coordinates and graticule.
ggplot(states_projected_sf) + geom_sf() + coord_sf() + theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 1))
Can someone explain where I went wrong and how to do this better?