Skip to contents

This function returns an sf object of cities (or populated places) with their populations and latitudes and longitudes. Population data is taken from the U.S. Census.

Usage

us_cities(map_date = NULL, states = NULL)

Arguments

map_date

If NULL, then city populations from the 2010 census (the most recent census) are returned. This parameter accepts a Date object or a character string coercible to a Date object, as well as numeric values representing a year. If a year or date is used, then city populations from the decennial census from 1790 to 2010 prior to that year is returned. For example, 1805 or "1805-07-04" would return city populations from the 1800 census.

states

A character vector of state or territory names or abbreviations. Only boundaries for those states/territories will be returned. If NULL, all boundaries will be returned.

References

The data was compiled by Erik Steiner and Jason Heppler at the Center for Spatial and Textual Analysis, Stanford University. See their description of the data for a fuller accounting of how the data was gathered.

Examples

if (require(USAboundariesData)) {
  us_cities(1805)
  us_cities("1828-05-08")
  us_cities()
}
#> City populations for contemporary data come from the 2010 census.
#> Simple feature collection with 6932 features and 12 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -166.5251 ymin: 19.09679 xmax: -67.23919 ymax: 71.25408
#> Geodetic CRS:  WGS 84
#> # A tibble: 6,932 × 13
#>    city   state…¹ state…² county count…³ stplf…⁴ name_…⁵ city_…⁶ popul…⁷ place…⁸
#>    <chr>  <chr>   <chr>   <chr>  <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
#>  1 Ancho… Alaska  AK      THIRD… Third … 0203000 Anchor… US Cen… US Cen… Incorp…
#>  2 Barrow Alaska  AK      North… North … 0205200 Barrow… US Cen… US Cen… Incorp…
#>  3 Bethel Alaska  AK      Bethe… Bethel… 0206520 Bethel… US Cen… US Cen… Incorp…
#>  4 Fairb… Alaska  AK      FOURT… Fourth… 0224230 Fairba… US Cen… US Cen… Incorp…
#>  5 Homer  Alaska  AK      Kenai… Kenai … 0233140 Homer … US Cen… US Cen… Incorp…
#>  6 Juneau Alaska  AK      FIRST… First … 0236400 Juneau… US Cen… US Cen… Incorp…
#>  7 Kenai  Alaska  AK      Kenai… Kenai … 0238420 Kenai … US Cen… US Cen… Incorp…
#>  8 Ketch… Alaska  AK      FIRST… First … 0238970 Ketchi… US Cen… US Cen… Incorp…
#>  9 Kodiak Alaska  AK      Kodia… Kodiak… 0240950 Kodiak… US Cen… US Cen… Incorp…
#> 10 Kotze… Alaska  AK      North… Northw… 0241830 Kotzeb… US Cen… US Cen… Incorp…
#> # … with 6,922 more rows, 3 more variables: year <int>, population <int>,
#> #   geometry <POINT [°]>, and abbreviated variable names ¹​state_name,
#> #   ²​state_abbr, ³​county_name, ⁴​stplfips_2010, ⁵​name_2010, ⁶​city_source,
#> #   ⁷​population_source, ⁸​place_type