Maps

Author

Sarah Marcrum

Data Source

https://quickstats.nass.usda.gov/results/466778BB-552D-3C7C-B9B4-2BDE71F5AF1E

Summary

This graphic shows the primary crop in each Illinois county by acres harvested. I chose a color pallet with distinct colors to make it easy to distinguish the different crop designations for each county. Since a few counties did not have data, I chose to use a black outline on the map; this made it easy to see the county lines while also preventing the states without data (which are white) from blending into a white border. Making the map interactive allowed additional data (acres harvested, county names) to be shown in the tooltip instead of over-crowding the visualization.

#read data
data <- read.csv('IL_crops_2021.csv')
Warning: package 'dplyr' was built under R version 4.1.3
Warning: package 'data.table' was built under R version 4.1.3
# A tibble: 6 x 4
# Groups:   County [6]
  County    Commodity Data.Item                             Value  
  <chr>     <chr>     <chr>                                 <chr>  
1 ADAMS     HAY       HAY, (EXCL ALFALFA) - ACRES HARVESTED 8,830  
2 ALEXANDER SOYBEANS  SOYBEANS - ACRES HARVESTED            37,700 
3 BOND      SOYBEANS  SOYBEANS - ACRES HARVESTED            81,100 
4 BOONE     CORN      CORN, GRAIN - ACRES HARVESTED         74,100 
5 BROWN     WHEAT     WHEAT, WINTER - ACRES HARVESTED       620    
6 BUREAU    CORN      CORN, GRAIN - ACRES HARVESTED         248,000

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
Simple feature collection with 6 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -90.58353 ymin: 37.06818 xmax: -87.93717 ymax: 42.49505
Geodetic CRS:  NAD83
  STATEFP COUNTYFP COUNTYNS       AFFGEOID GEOID  County       NAMELSAD STUSPS
1      17      153 01784966 0500000US17153 17153 PULASKI Pulaski County     IL
2      17      007 00424205 0500000US17007 17007   BOONE   Boone County     IL
3      17      125 00424261 0500000US17125 17125   MASON   Mason County     IL
4      17      175 00424288 0500000US17175 17175   STARK   Stark County     IL
5      17      017 00424210 0500000US17017 17017    CASS    Cass County     IL
6      17      047 00424225 0500000US17047 17047 EDWARDS Edwards County     IL
  STATE_NAME LSAD      ALAND   AWATER     Crop                       Data.Item
1   Illinois   06  516100615  9768333    WHEAT WHEAT, WINTER - ACRES HARVESTED
2   Illinois   06  727114618  3360626     CORN   CORN, GRAIN - ACRES HARVESTED
3   Illinois   06 1396914848 62748513 SOYBEANS      SOYBEANS - ACRES HARVESTED
4   Illinois   06  746156213   684784     CORN   CORN, GRAIN - ACRES HARVESTED
5   Illinois   06  973198204 20569928     CORN   CORN, GRAIN - ACRES HARVESTED
6   Illinois   06  576012470   781202 SOYBEANS      SOYBEANS - ACRES HARVESTED
   Acres                       geometry
1  5,280 MULTIPOLYGON (((-89.27363 3...
2 74,100 MULTIPOLYGON (((-88.94099 4...
3 93,700 MULTIPOLYGON (((-90.35452 4...
4 85,000 MULTIPOLYGON (((-89.98538 4...
5 79,000 MULTIPOLYGON (((-90.58353 3...
6 50,000 MULTIPOLYGON (((-88.15049 3...
library(ggplot2)
library(ggdendro)
library(paletteer)
library(plotly)

# define highlight key
hl <- highlight_key(IL_harvest, ~County)

# create map
p_harvest <- ggplot(data = hl) + 
  geom_sf(color="black", aes(geometry = geometry, fill=Crop, label=County, label2=Acres))
p_harvest <- p_harvest + ggdendro::theme_dendro()
p_harvest <- p_harvest + guides(fill=guide_legend(title="Top Crop by Acres Harvested"))
p_harvest <- p_harvest +  coord_sf() + scale_fill_paletteer_d("rtist::picasso") 
p_harvest <- p_harvest + ggtitle("Top Crops in Illinois Counties")

p_harvest

#make it interactive!

plt <- ggplotly(p_harvest, tooltip = c("County", "Crop", "Acres")) %>% highlight(
  on = "plotly_hover",
  off = "plotly_relayout"
)

plt