Skip to content

Annotation_map does not work with coord_sf #3653

Closed
@markpayneatwork

Description

@markpayneatwork

When usingcoord_sf() to change the projection of a map, the background layer produced by annotation_map() is not getting reprojected.

First, a plot without changing projection, using the annotation_map layer to give more context to North Carolina

library(ggplot2)
library(sf)
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)

ggplot() +
  annotation_map(map_data("state"),fill="antiquewhite",colour="darkgrey")+
  geom_sf(data = nc)

image

However, changing the projection looses the annotation layer, but reprojects the geometry layer

ggplot() +
  annotation_map(map_data("state"),fill="antiquewhite",colour="darkgrey")+
  geom_sf(data = nc)+
  coord_sf(crs = st_crs(3347))

image

It looks to me like the annotation_layer is not being reprojected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions