statemap_labels: State map label longitude and latitude points.

Description Usage Format Details Source Examples

Description

Longitude (x) and latitude (y) values for points suitable for putting state abbreviations or names on a map of the 50 states generated by usmap::us_map().

Usage

1

Format

Data frame with 1 row per state per state.

x

Longitude, numeric

y

Latitude, numeric

fips

State FIPS code, character

stabbr

State postal abbreviation, character

stname

State name, character

Details

It is difficult to determine algorithmically precisely where these points should be – centroids or simple midpoints of a state's longitude and latitude are not always best. Good labeling points have been developed in the package usmap. This data frame uses those points.

Having the data points in a separate data frame allows them to be used in ways beyond those built into the package usmap.

Includes 50 states and DC. Alaska and Hawaii are in the lower left corner of the map and the labels are placed there.

Source

usmap package developed by Paolo Di Lorenzo (see https://dilorenzo.pl/pkgs/usmap/). The GitHub package page is https://github.com/pdil/usmap and the specific file location is https://github.com/pdil/usmap/blob/master/inst/extdata/us_states_centroids.csv. At CRAN: https://cran.r-project.org/web/packages/usmap/index.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  head(statemap_labels)
  
## Not run: 
  # check how the labeling looks on a U.S. map
  p <- ggplot(data = usmap::us_map(), aes(x = x, y = y)) +
    geom_polygon(aes(group=group), fill="white", color = "gray90", size = 0.1, na.rm=TRUE) +
    coord_equal()
  p
  
  p + geom_text(data = statemap_labels, aes(x, y, label = stabbr), size = 2)
  
  p + geom_text(data = statemap_labels, aes(x, y, label = stname), size = 2)

## End(Not run)
  

donboyd5/bdata documentation built on Jan. 16, 2022, 1:24 p.m.