Skip to contents

Overview

This vignette walks through the process of retrieving geographic metadata used for filtering legacy NCCS files. The legacy data consists of several relevant geographic variables:

  • STATE: 2 letter state abbreviation (all caps)
  • CITY: Name of the city associated with the address provided in ADDRESS (all caps)
  • FIPS: County FIPS Codes. Federal Information Processing System (FIPS) codes as used by the US Census (5 digit integer)

The last variable FIPS can be used to match observations based on Census units. This preserves the external validity of geographic units by operationalizing them according to U.S. Census delineations.

In US Census data,FIPS are also tied to Core Based Statistical Areas (CBSAs) that consist mutually exclusive Metropolitan, (metros with populations above 50,000) and Micropolitan Statistical Areas (populations above 10,000 and below 50,000). Further details and examples are provided on the Census Crosswalks page of the Urban NCCS Site. Thus, geographic filtering with US Census units requires crosswalking units across multiple levels, such as county and CBSA.

In this vignette, we will first explore these CBSA FIPS codes with the geo_preview() function before demonstrating how these CBSA FIPS can be linked to county FIPS codes via map_countyfips().

Exploring CBSA FIPS codes

The geo_preview() function allows users to preview and retrieve CBSA FIPS codes and/or their associated metadata from a specific state. In the following code snippet, geo_preview() returns the names of all CBSAs and their associated FIPS codes. The within argument takes the desired state, in abbreviated form, as input while the geo argument returns the specified columns.

geo_preview( geo=c("cbsa","cbsafips"), within="FL", type="metro" )
#> 
#> 
#> |                                        cbsa| cbsafips|
#> |-------------------------------------------:|--------:|
#> |                             Gainesville, FL|    23540|
#> |                            Jacksonville, FL|    27260|
#> |           Panama City-Panama City Beach, FL|    37460|
#> |           Palm Bay-Melbourne-Titusville, FL|    37340|
#> |   Miami-Fort Lauderdale-West Palm Beach, FL|    33100|
#> |                             Punta Gorda, FL|    39460|
#> |                       Homosassa Springs, FL|    26140|
#> |                     Naples-Marco Island, FL|    34940|
#> |              Pensacola-Ferry Pass-Brent, FL|    37860|
#> |      Deltona-Daytona Beach-Ormond Beach, FL|    19660|
#> |                             Tallahassee, FL|    45220|
#> |         Tampa-St. Petersburg-Clearwater, FL|    45300|
#> |                                 Sebring, FL|    42700|
#> | Sebastian-Vero Beach-West Vero Corridor, FL|    42680|
#> |               Orlando-Kissimmee-Sanford, FL|    36740|
#> |                   Cape Coral-Fort Myers, FL|    15980|
#> |           North Port-Bradenton-Sarasota, FL|    35840|
#> |                                   Ocala, FL|    36100|
#> |                          Port St. Lucie, FL|    38940|
#> |      Crestview-Fort Walton Beach-Destin, FL|    18880|
#> |                   Lakeland-Winter Haven, FL|    29460|
#> |                   Wildwood-The Villages, FL|    48680|

In the above code chunk, the function returns the names of all CBSAs and their associated FIPS codes. within takes the desired state as input while geo returns the specified columns. geo can also be used to return county metadata.

geo_preview(geo = c("cbsa", "county", "cbsafips"), within = "FL", type = "metro")
#> 
#> 
#> |                                        cbsa|                           county| cbsafips|
#> |-------------------------------------------:|--------------------------------:|--------:|
#> |                             Gainesville, FL|      Alachua County, FL, Central|    23540|
#> |                            Jacksonville, FL|       Baker County, FL, Outlying|    27260|
#> |           Panama City-Panama City Beach, FL|          Bay County, FL, Central|    37460|
#> |           Palm Bay-Melbourne-Titusville, FL|      Brevard County, FL, Central|    37340|
#> |   Miami-Fort Lauderdale-West Palm Beach, FL|      Broward County, FL, Central|    33100|
#> |                             Punta Gorda, FL|    Charlotte County, FL, Central|    39460|
#> |                       Homosassa Springs, FL|       Citrus County, FL, Central|    26140|
#> |                            Jacksonville, FL|         Clay County, FL, Central|    27260|
#> |                     Naples-Marco Island, FL|      Collier County, FL, Central|    34940|
#> |                            Jacksonville, FL|        Duval County, FL, Central|    27260|
#> |              Pensacola-Ferry Pass-Brent, FL|     Escambia County, FL, Central|    37860|
#> |      Deltona-Daytona Beach-Ormond Beach, FL|      Flagler County, FL, Central|    19660|
#> |                             Tallahassee, FL|     Gadsden County, FL, Outlying|    45220|
#> |                             Gainesville, FL|   Gilchrist County, FL, Outlying|    23540|
#> |         Tampa-St. Petersburg-Clearwater, FL|    Hernando County, FL, Outlying|    45300|
#> |                                 Sebring, FL|    Highlands County, FL, Central|    42700|
#> |         Tampa-St. Petersburg-Clearwater, FL| Hillsborough County, FL, Central|    45300|
#> | Sebastian-Vero Beach-West Vero Corridor, FL| Indian River County, FL, Central|    42680|
#> |                             Tallahassee, FL|   Jefferson County, FL, Outlying|    45220|
#> |               Orlando-Kissimmee-Sanford, FL|        Lake County, FL, Outlying|    36740|
#> |                   Cape Coral-Fort Myers, FL|          Lee County, FL, Central|    15980|
#> |                             Tallahassee, FL|         Leon County, FL, Central|    45220|
#> |                             Gainesville, FL|        Levy County, FL, Outlying|    23540|
#> |           North Port-Bradenton-Sarasota, FL|      Manatee County, FL, Central|    35840|
#> |                                   Ocala, FL|       Marion County, FL, Central|    36100|
#> |                          Port St. Lucie, FL|       Martin County, FL, Central|    38940|
#> |   Miami-Fort Lauderdale-West Palm Beach, FL|   Miami-Dade County, FL, Central|    33100|
#> |                            Jacksonville, FL|      Nassau County, FL, Outlying|    27260|
#> |      Crestview-Fort Walton Beach-Destin, FL|     Okaloosa County, FL, Central|    18880|
#> |               Orlando-Kissimmee-Sanford, FL|       Orange County, FL, Central|    36740|
#> |               Orlando-Kissimmee-Sanford, FL|     Osceola County, FL, Outlying|    36740|
#> |   Miami-Fort Lauderdale-West Palm Beach, FL|   Palm Beach County, FL, Central|    33100|
#> |         Tampa-St. Petersburg-Clearwater, FL|        Pasco County, FL, Central|    45300|
#> |         Tampa-St. Petersburg-Clearwater, FL|     Pinellas County, FL, Central|    45300|
#> |                   Lakeland-Winter Haven, FL|         Polk County, FL, Central|    29460|
#> |                            Jacksonville, FL|    St. Johns County, FL, Central|    27260|
#> |                          Port St. Lucie, FL|    St. Lucie County, FL, Central|    38940|
#> |              Pensacola-Ferry Pass-Brent, FL|   Santa Rosa County, FL, Central|    37860|
#> |           North Port-Bradenton-Sarasota, FL|     Sarasota County, FL, Central|    35840|
#> |               Orlando-Kissimmee-Sanford, FL|     Seminole County, FL, Central|    36740|
#> |                   Wildwood-The Villages, FL|       Sumter County, FL, Central|    48680|
#> |      Deltona-Daytona Beach-Ormond Beach, FL|      Volusia County, FL, Central|    19660|
#> |                             Tallahassee, FL|     Wakulla County, FL, Outlying|    45220|
#> |      Crestview-Fort Walton Beach-Destin, FL|       Walton County, FL, Central|    18880|
#> |           Panama City-Panama City Beach, FL|  Washington County, FL, Outlying|    37460|

Metropolitan and Micropolitan Data

Since CBSAs include a combination of metropolitan or micropolitan statistical areas, geo_preview() allows the user to select either unit using the type argument.

The below code snippet returns the CBSA names and FIPS codes for all metropolitan statistical areas in Wyoming.

geo_preview(geo = c("cbsa","cbsafips"), within = "WY", type = "micro")
#> 
#> 
#> |             cbsa| cbsafips|
#> |----------------:|--------:|
#> |      Laramie, WY|    29660|
#> |     Gillette, WY|    23940|
#> |     Riverton, WY|    40180|
#> |         Cody, WY|    17650|
#> |     Sheridan, WY|    43260|
#> | Rock Springs, WY|    40540|
#> |   Jackson, WY-ID|    27220|
#> |  Evanston, WY-UT|    21740|

Setting type to micro returns data for micropolitan statistical areas.

geo_preview(geo = c("cbsa","cbsafips"), within = "WY", type = "metro")
#> 
#> 
#> |         cbsa| cbsafips|
#> |------------:|--------:|
#> | Cheyenne, WY|    16940|
#> |   Casper, WY|    16220|

Exploring CSA FIPS

In addition to CBSAs, geo_preview() can also retrieve metadata for Combined Statistical Areas (CSAs).

CSAs (populations that form a coherent commercial and commuting zone) are created by identifying adjacent micropolitant and metropolitan statistical areas that constitute a coherent economic region.

The code snippet below returns all CSA names and FIPS codes for metropolitan statistical areas in Virginia.

geo_preview(geo = c("cbsa", "cbsafips", "csa","csafips"), 
            within = "VA", 
            type = "metro")
#> 
#> 
#> |                                         cbsa| cbsafips|                                            csa| csafips|
#> |--------------------------------------------:|--------:|----------------------------------------------:|-------:|
#> |                          Charlottesville, VA|    16820|                                               |      NA|
#> |                                 Richmond, VA|    40060|                                               |      NA|
#> |                                Lynchburg, VA|    31340|                                               |      NA|
#> | Washington-Arlington-Alexandria, DC-VA-MD-WV|    47900| Washington-Baltimore-Arlington, DC-MD-VA-WV-PA|     548|
#> |                   Staunton-Stuarts Draft, VA|    44420|        Harrisonburg-Staunton-Stuarts Draft, VA|     277|
#> |                                  Roanoke, VA|    40220|                                               |      NA|
#> |        Blacksburg-Christiansburg-Radford, VA|    13980|                                               |      NA|
#> |                            Winchester, VA-WV|    49020| Washington-Baltimore-Arlington, DC-MD-VA-WV-PA|     548|
#> |     Virginia Beach-Chesapeake-Norfolk, VA-NC|    47260|               Virginia Beach-Chesapeake, VA-NC|     545|
#> |                             Harrisonburg, VA|    25500|        Harrisonburg-Staunton-Stuarts Draft, VA|     277|
#> |                     Kingsport-Bristol, TN-VA|    28700|          Johnson City-Kingsport-Bristol, TN-VA|     304|

Since CSAs are combination of various Micropolitan and Metropolitan areas, not all CBSAs will fall under a CSA, and hence CSA FIPS are only available for existing CSAs.

Filtering Legacy Data with County FIPS codes

After retrieving the desired CBSA/CSA FIPS codes, map_countyfips() can be used to match these with county FIPS codes present in the legacy data, retrieved with get_data(). Downloaded data can then be filtered using these county FIPS codes as shown below.

# Retrive CBSA FIPS from NY
cbsa_ny <- geo_preview(geo = c("cbsa", "cbsafips"), 
                       within = "NY")
#> 
#> 
#> |                                  cbsa| cbsafips|
#> |-------------------------------------:|--------:|
#> |           Albany-Schenectady-Troy, NY|    10580|
#> |    New York-Newark-Jersey City, NY-NJ|    35620|
#> |                        Binghamton, NY|    13780|
#> |                             Olean, NY|    36460|
#> |                            Auburn, NY|    12180|
#> |                 Jamestown-Dunkirk, NY|    27460|
#> |                            Elmira, NY|    21300|
#> |                       Plattsburgh, NY|    38460|
#> |                            Hudson, NY|    26460|
#> |                          Cortland, NY|    18660|
#> | Kiryas Joel-Poughkeepsie-Newburgh, NY|    28880|
#> |               Buffalo-Cheektowaga, NY|    15380|
#> |                      Gloversville, NY|    24100|
#> |                           Batavia, NY|    12860|
#> |                        Utica-Rome, NY|    46540|
#> |               Watertown-Fort Drum, NY|    48060|
#> |                         Rochester, NY|    40380|
#> |                          Syracuse, NY|    45060|
#> |                         Amsterdam, NY|    11220|
#> |                           Oneonta, NY|    36580|
#> |                Massena-Ogdensburg, NY|    32390|
#> |                      Seneca Falls, NY|    42900|
#> |                           Corning, NY|    18500|
#> |                        Monticello, NY|    33910|
#> |                            Ithaca, NY|    27060|
#> |                          Kingston, NY|    28740|
#> |                       Glens Falls, NY|    24020|

# Map these to county FIPS codes
ny_countyfips <- map_countyfips(geo.cbsafips = cbsa_ny$cbsafips)

# Pull core data for the year 2015
core_2015 <- get_data(dsname = "core",
                      time = "2015",
                      scope.orgtype = "NONPROFIT",
                      scope.formtype = "PZ")
#> Valid inputs detected. Retrieving data.
#> Downloading core data
#> Requested files have a total size of 115 MB. Proceed
#>                       with download? Enter Y/N (Yes/no/cancel)
#> Core data downloaded

# Filter with NY county FIPS
core_2015_nyfips <- core_2015 %>% 
  dplyr::filter(FIPS %in% ny_countyfips)