urbnmapr

A simple solution to a common problem

urbnmapr makes a few variations of the same basic map.

How it works

Installation

The package lives on GitHub. The devtools package makes it easy to install straight from the source.

devtools::install_github("UrbanInstitute/urbnmapr")

Functionality

states <- get_urbn_map(map = "states", sf = TRUE)
##   state_fips state_abbv state_name                       geometry
## 1         01         AL    Alabama MULTIPOLYGON (((1150023 -15...
## 2         02         AK     Alaska MULTIPOLYGON (((-1273178 -2...
## 3         04         AZ    Arizona MULTIPOLYGON (((-1386136 -1...
## 4         05         AR   Arkansas MULTIPOLYGON (((482001 -928...
## 5         06         CA California MULTIPOLYGON (((-1717278 -1...

You can merge your data onto this dataframe to make choropleth maps.

geographic_data <- left_join(states, statedata, 
                             by = "state_name")

Making maps

ggplot() +
  geom_sf(data = geographic_data,
          mapping = aes(fill = medhhincome),
          color = "white") +
  scale_fill_gradientn(labels = scales::dollar) +
  coord_sf(datum = NA) +
  urbnthemes::theme_urbn_map() +
  labs(fill = "Median household income")

Extensions

Mapping individual states

For more information

Visit the urbnmapr GitHub page for more detailed instructions.

The Urban Institute mapping guide is currently in progress!

Why R?

Why R?

  • Reproducibility

  • Make the same map 100 times

  • It’s free

  • Geospatial analysis in R is constantly evolving

Why a package?

Why a package?

  • Portable

  • Lowers the barrier to entry

  • Push updates when we need to

  • Cool hex stickers

R @ Urban

R @ Urban

We create tools to help researchers do their jobs more efficiently- whether it is running trainings, building packages, or writing detailed guides.

You can follow along: