Skip to contents

Get U.S. states and counties using a very fast query.

Usage

get_states(
  location = NULL,
  dist = NULL,
  diag_ratio = NULL,
  unit = NULL,
  asp = NULL,
  class = "df",
  ...
)

get_counties(
  location = NULL,
  dist = NULL,
  diag_ratio = NULL,
  unit = NULL,
  asp = NULL,
  class = "df",
  ...
)

Arguments

location

A sf, sfc, or bbox object or a character string that matches a geoid, name, abb, or statefp for us_states or us_counties.

dist

buffer distance in units. Optional.

diag_ratio

ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when dist is provided.

unit

Units for buffer. Supported options include "meter", "foot", "kilometer", and "mile", "nautical mile" Common abbreviations (e.g. "km" instead of "kilometer") are also supported. Distance in units is converted to units matching GDAL units for x; defaults to "meter"

asp

Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3"). If numeric, get_asp() returns the same value without modification.

class

Class of data to return, "df" (default), "sf", "bbox", or "sfc"

...

Additional parameters including geoid or name. For get_states(), additional parameters can be abb or statefp.

Examples

get_states(
  location = "Maryland"
)
#> # A tibble: 1 × 7
#>   name     geoid abb   est_pop statefp bbox       wkt                           
#>   <chr>    <chr> <chr>   <dbl> <chr>   <list>     <chr>                         
#> 1 Maryland 24    MD    6018848 24      <bbox [4]> MULTIPOLYGON (((-8465780 4578…

get_counties(
  location = "Baltimore city, Maryland"
)
#> # A tibble: 1 × 9
#>   name                name_…¹ abb_s…² est_pop geoid count…³ statefp bbox   wkt  
#>   <chr>               <chr>   <chr>     <dbl> <chr> <chr>   <chr>   <list> <chr>
#> 1 Baltimore city, Ma… Baltim… MD       609032 24510 510     24      <bbox> MULT…
#> # … with abbreviated variable names ¹​name_short, ²​abb_state, ³​countyfp

get_states(
  location = "24",
  class = "sf"
)
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -8848525 ymin: 4566962 xmax: -8354410 ymax: 4825788
#> Projected CRS: WGS 84 / Pseudo-Mercator
#> # A tibble: 1 × 6
#>   name     geoid abb   est_pop statefp                                  geometry
#>   <chr>    <chr> <chr>   <dbl> <chr>                          <MULTIPOLYGON [m]>
#> 1 Maryland 24    MD    6018848 24      (((-8465780 4578058, -8465715 4580663, -…