I'm making a fairly detailed map of the northern high latitudes that I want to show with an Arctic projection. I'd like to have a map that has a transparent circle from 50N to 90N as a mask for the final image. Seems easy. But I'm stuck. What I'd like is for the map in p1 below to be reprojected into North Pole Azimuthal Equidistant projection with the data below 50N to be greyed out and the data above 50N to show through. Any tips?
library(sf)
library(tidyverse)
#get coastlines as a demo
coastlines <- rnaturalearth::ne_coastline(scale = 50, returnclass = "sf")
st_crs(coastlines) <- "EPSG:4326"
# create arctic(ish) bounding box
arcticBox <- data.frame(id="A",
lon = c(-180,180,180,-180,-180),
lat = c(90,90,50,50,90))
otherBox <- data.frame(id="B",
lon = c(-180,180,180,-180,-180),
lat = c(50,50,-90,-90,50))
boxes <- bind_rows(arcticBox,otherBox)
boxesSF <- st_as_sf(boxes,coords=c("lon","lat"),crs="EPSG:4326") %>%
group_by(id) %>% summarise(geometry = st_combine(geometry)) %>%
st_cast("POLYGON")
p1 <- ggplot() +
geom_sf(data=coastlines,color="blue",size=0.25) +
geom_sf(data=boxesSF,mapping = aes(fill=id),color=NA) +
scale_fill_manual(values=alpha(colour=c("blue", "grey"),
alpha = c(0,1))) +
coord_sf(ylim = c(0,90)) +
theme(legend.position = "none")
p1
p1 + coord_sf(crs = sf::st_crs("ESRI:102016"))
Where did the masking polygons go? Something weird with having -180 to 180 meeting?

