From the course: Creating Maps with R

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Zoom into regions with coords_sf()

Zoom into regions with coords_sf()

From the course: Creating Maps with R

Zoom into regions with coords_sf()

- Sometimes we want to zoom into a map to focus on specific features. For instance, in this map of hospitals in Oregon, it's clear that highest density of hospitals is in the Northwest. And specifically in Multnomah County. When we build interactive maps with packages like leaflet it's really easy for the reader to zoom into a region. But when we use ggplot2 to create static maps this process requires some thought. We could try to filter our data set to show only the border for Multnomah but that removes some important context from the map. So we need a way to zoom into the map by specifying limits for the X and Y coordinates. Let's load up the script in your 0 4 0 5 B project and start running our code line 7 through 1. We're going to load our packages. And we're also going to obtain shaped files for the counties of Oregon. Takes a couple of seconds to download these onto your machine. And then lines 9 through 12,…

Contents