Author: Paolo Di Lorenzo
Date: 2025-08-28

# 1. Introduction

#### Paolo Di Lorenzo

#### 2025-08-28

## Plotting

Plots of US maps in R usually lack Alaska, Hawaii, and Puerto Rico. The reason is plotting takes the literal longitude and latitude coordinates and maps it to a cartesian x-y coordinate graph. Alaska, Hawaii, and Puerto Rico are very far from the mainland US when using this so it can be unwieldy to include them. The `usmap` package solves this issue by providing data frames which have Alaska, Hawaii, and Puerto Rico moved to a convenient spot just to the bottom left of the contiguous United States.

#### Blank US state map

    usmap::plot_usmap()

#### Blank US county map

    usmap::plot_usmap(regions = "counties")

## Raw map data

The raw US map data for counties or states can be obtained for further manipulation (and joining with data). The default `regions` is `"states"`.

    states_df <- usmap::us_map()
    counties_df <- usmap::us_map(regions = "counties")

## FIPS codes

FIPS codes are defined in the Federal Information Processing Standards by the US government. One usage is uniquely identifying US states and counties. Downloaded data sets from the US Census will often include FIPS codes as identifiers so it can be helpful to know what a FIPS code represents. The functions in `usmap` are built around the FIPS code identification system and so convenience methods for accessing them and performing reverse-lookups have been included.

#### State/County FIPS lookup

    # Get FIPS code for a state
    usmap::fips(state = "MA")
    #> [1] "25"
    usmap::fips(state = "Massachusetts")
    #> [1] "25"

    # Get FIPS code for a county
    usmap::fips(state = "NJ", county = "Bergen")
    #> [1] "34003"
    usmap::fips(state = "CA", county = "Orange County")
    #> [1] "06059"

    # The parameters are NOT case sensitive!
    usmap::fips(state = "ca", county = "oRanGe cOUNty")
    #> [1] "06059"

#### FIPS reverse lookup

If the FIPS code is known and want to see what state/county it corresponds to, use the reverse lookup function `fips_info`.

    usmap::fips_info(c("30", "33", "34"))
    #>   abbr fips          full
    #> 1   MT   30       Montana
    #> 2   NH   33 New Hampshire
    #> 3   NJ   34    New Jersey

    usmap::fips_info(c("01001", "01003", "01005", "01007"))
    #>      full abbr         county  fips
    #> 1 Alabama   AL Autauga County 01001
    #> 2 Alabama   AL Baldwin County 01003
    #> 3 Alabama   AL Barbour County 01005
    #> 4 Alabama   AL    Bibb County 01007

#### Further reading

More information about FIPS can be read here.

> “A map is the greatest of all epic poems. Its lines and colors show the realization of great dreams.” - Gilbert H. Grosvenor, Editor of National Geographic (1903 - 1954)