Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posts/2023-10-31-map-context/index #22

Open
utterances-bot opened this issue Nov 10, 2023 · 1 comment
Open

posts/2023-10-31-map-context/index #22

utterances-bot opened this issue Nov 10, 2023 · 1 comment

Comments

@utterances-bot
Copy link

Mike Mahoney - Adding context to maps made with ggplot2

How to set the extent of a map based upon a single layer.

https://www.mm218.dev/posts/2023-10-31-map-context/index.html

Copy link

PaulC91 commented Nov 10, 2023

You can use a bbox to set the limits within coord_sf:

bbox <- st_bbox(johnston_obs)

ggplot() +
  geom_sf(data = nc) +
  geom_sf(data = johnston_obs, color = "red") +
  coord_sf(
    xlim = c(bbox[["xmin"]], bbox[["xmax"]]),
    ylim = c(bbox[["ymin"]], bbox[["ymax"]]),
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants