A few months ago, I wrapped up a freelance project that made heavy use of the USDA Quick Stats data. It’s a super neat compilation of agricultural data that was begging to be made into nicer maps than the source site provides.
I was immediately interested in finding out where specific crops were grown across the USA. In particular, I wanted to know what the most common crop was in each county.
The answer, of course, depends on how you define “common.” After browsing the data, I decided that “acres harvested” would work best for my purposes for a couple of reasons:
- It was available for a large number of crops, whereas other values, like “amount harvested” were not
- It was standard across all crop types. One acre is one acre, but a bushel is not easily translated into pounds, for example.
- It reflects the physical reality of the land. These are the crops that take up the most physical space in each county, which worked well to answer my question.
And the answer is…
Hay! (Followed by corn, soybeans, and wheat)
Bonus maps, from fruit to nuts
Yeah, it’s soup to nuts, but let me have my dumb pun.
Is it a character flaw that I can’t ever make just one map? Maybe, cause I never get anything done on a reasonable timeline.
But hey, enjoy these category-specific maps. They’re not necessarily good (I can hear my editor screaming that they should be bar charts), but I love them in all their busy wackiness.
But wait, there’s more!
I really can’t help myself, can I?
How I did it
Luckily, there’s a great R wrapper for the USDA stat site: TidyUSDA. It makes getting all the data a snap.
You’ll first need to sign up for a USDA API key.
Install and load R libraries
Get a variable of all possible commodities listed in the USDA site.
Now we’ll loop through each commodity and check if there’s county level data for it. Additionally, we’ll filter down to just the data that’s expressed as a number of acres. I’m doing it this way because I didn’t feel like researching which commodities had “acres harvested” data available and which didn’t. This ain’t pretty and it ain’t fast, but it works.
And there you go, a big ol’ csv file with crops in it. Handy!
On the colors
Picking colors for a 14-class choropleth is a nightmare. (And again, I can hear my editor saying to either make it a bar chart or choose just 3-4 classes. But that’s lame and boring.)
I took a bit of a shortcut by harvesting colors I liked from geologic maps, which are both pretty and extremely colorful.
In the future, I’d like to take my initial palettes and run them through Matt Ström’s super interesting optimization algorithm to hopefully gain something a bit more readable and color-blind friendly.