What is a FIPS code? County-level charts in Python

Plotly
Plotly
Published in
6 min readMay 1, 2018

FIPS codes are five-digit codes that are assigned to each U.S. county. The first two digits identify the state and the last three identify the county.

Think of it like a fancy version of a ZIP Code or postal code that distinguishes a county.

FIPS codes are easier to utilize in data and information systems than state and county names. This makes datasets that come packaged with FIPS codes a portal into national, state, and county-level graphical and/or statistical analyses for a variety of topics.

Curious about your FIPS code? Find out here.

In this post, we’ll investigate some data from the Institute for Health Metrics and Evaluation from its Global Health Data Exchange resource. This data is easy to read into Plotly, as we’ll demonstrate, since FIPS codes are included in the files.

If health-related data is your thing, check out our recent post “Assessing Global Health, One 📈 at a Time.”

County-level maps in Plotly can reveal spatial patterns, trends, and local tendencies within the dataset you are examining. Hover-over your home county and engage with the data instead of looking at a legend and guessing a value.

For more on USA county-level choropleth maps in Python, head here.

Alcohol Use Disorders

This map investigates the percent change in alcohol use disorders between 1980 and 2014. At a full-U.S. scale it is a busy map, but several areas stand out:

  • Alcohol use disorders have decreased, in some cases significantly, across the Carolinas.
  • The largest increases are spread far and wide, although the Ohio Valley and Pennsylvania are particularly noticeable, as well as the Four Corners region.
  • The decrease over the years across South Dakota and Nebraska sticks out amidst a sea of red.
Source | Data | Python code

Zooming In

By using Plotly’s “scope” function, we can zoom down to a low level and obtain more detail:

States = ['VA', 'NC', 'SC'] 
# Specify states of interest
df_sample_r = df_sample[df_sample['State Name'].isin(States)]
# Read in state names
scope=States,
# Define your scope

We can now closely examine the three states that had the largest decrease in alcohol use disorders during 1980 to 2014. Central North Carolina is the epicenter, with Durham County posting a massive 82.5% decrease in the 34 year period, second to only Miami-Dade County in south Florida for the biggest drop in the United States.

Source | Data | Code

Diabetes Prevalence

In the October 31, 2008 issue of Morbidity and Mortality Weekly Report, Centers for Diseases and Prevention reported that the incidence of new onset diagnosed diabetes in U.S. adults had increased by 90% over the previous decade.

The map below, which examines the percent change in diabetes prevalence between 1999 and 2012, certainly supports that statistic.

The states with the largest burden increases include Kansas, Oklahoma, Arkansas, and Missouri, as well as western Tennessee and Kentucky.

This region sits just west and north of the so-called “diabetes belt,” so it is a potential indicator that the region is expanding.

Source | Data | Python code

A Closer Look

Here, we hone in on four central U.S. states that have seen a large increase in diabetes prevalence recently.

Benton County in northwest Arkansas saw an increase of 62.4% and Seward County in southwest Kansas observed an increase of 68.8%, which are not only chart topping locally but on the national level as well.

The keen geographer would be able to differentiate between the states without borders, but for the rest of us, dark gray state borders can only help.

Notice below we use white county borders to make them pop and black state borders so that those stand out clearly.

county_outline={'color': 'rgb(255,255,255)', 'width': 0.5}, 
# Specify your county borders

state_outline={'color': 'rgb(68,68,68)', 'width': 1},
# Specify your state borders
Source | Data | Python code

Interpersonal Violence

Between 1980 and 2014, the percentage of counties in which mortality rates decreased from interpersonal violence was 93.4%.

The green colors indicate counties where interpersonal violence has trended downward. This was especially clear in Texas and across the Deep South; chiefly Florida and Georgia, as well as into Appalachia.

California also featured significant decreases.

On the other hand, red shades show where interpersonal violence increased. This occurred in patches across the Midwest and Ohio Valley, but was most prominent in eastern Pennsylvania and upstate New York.

Source | Data | Python code

Ohio Stands Out

Many states, particularly across the south and west, observed a reduction in interpersonal violence between 1980 and 2014. However, there is a pocket of states in the northeastern corner of the U.S. that had some increases.

Central and eastern Ohio contains one of those pockets, where Franklin County tallied a 67% increase in interpersonal violence during the 24-year period.

Between 1980 and 2014, the percentage of counties in which mortality rates increased from interpersonal violence was just 6.6% — a number propelled forward by states like Ohio, Pennsylvania, and New York.

Notice below we use a gray plot background color to make our state pop out a little more.

plot_bgcolor='rgb(229,229,229)', 
# Specify the background color of your plot
paper_bgcolor='rgb(229,229,229)',
Source | Data | Python code

Where do your Avocados come from? 🥑

U.S. avocados are commercially grown in California, Texas, and Florida across the Lower 48. In terms of total avocado-producing acreage, The Golden State accounts for over 81%.

Outside of California, Miami-Dade County in South Florida has almost 11,700 avocado bearing acres, good for third highest north of the (Mexican) border.

Unsurprisingly, the avocado tree does not tolerate freezing temperatures and can only be grown in subtropical or tropical climates like Florida, California, Texas, Mexico, and New Zealand.

Source | Data | Python code

California-cado

According to the California Avocado Commission, California is the top producer of avocados in the United States and home to 95% of the country’s crop. There are approximately 6,000 growers in the state, a majority of which are located in San Diego County.

In fact, San Diego County alone produces about 40% of California’s avocados and has nearly 18,000 avocado-bearing acres of land. Ventura County has the second most avocado-bearing acres in the state with over 15,500.

Source | Data | Python code

California’s Central Valley the Almond Epicenter

Kern County, in California’s Mediterranean Central Valley, is home to the most almond-bearing acres in the United States — nearly 144,000 as of 2012.

In fact, California almonds comprise 99.99% of production in the lower 48 AND approximately 62% of the world stock.

Almonds are also cultivated in Spain, Iran, Morocco, Italy, and Australia.

Source | Data | Python code

Where you’re Most Likely to see a U-Haul

Between 2016 and 2017, the independent city of Falls Church, Virginia, very close to Washington D.C. had the largest migration (or number of new residents) per 1,000 population for a locality that has more than 10,000 residents.

5 biggest migrant increases, by county [location | migrants per 1,000 population]

  1. Falls Church, Virginia| 49.02
  2. Comal County, Texas |48.69
  3. Wasatch County, Utah | 47.81
  4. Hays County, Texas |47.27
  5. Kendall County, Texas | 46.84

5 biggest migrant decreases, by county [location | migrants per 1,000 population]

  1. Campbell County, Wyoming | -55.31
  2. Martin County, Kentucky | -43.22
  3. Cheyenne County, Nebraska | -40.31
  4. Geary County, Kansas | -39.96
  5. McDowell County, West Virginia | -37.01
Source | Data | Python code

Migration, Normalized

For another perspective, here is the same data as above but standardized. The growth across the western U.S. is evident, along with the sliding population across the northern Plains and northeastern Rockies (fossil fuel slump).

For a refresher on normal distributions, recall the 68–95–99.7 rule.

Source | Data | Python code

Colorscales

Looking for the right colorscale to complement your choropleth map? Look no further: https://react-colorscales.getforge.io/.

For the alcohol use map, we used “balance”

For the diabetes prevalence map, we used “Viridis”

For the interpersonal violence map, used “curl”

County-level maps in Plotly can reveal spatial patterns, trends, and local tendencies within the dataset you are examining. Hover-over your home county and engage with the data instead of looking at a legend and guessing a value.

--

--

Plotly
Plotly
Editor for

The low-code framework for rapidly building interactive, scalable data apps in Python.