https://github.com/bradlindblad/tidyusda
An interface to USDA Quick Stats data with mapping capabilities.
https://github.com/bradlindblad/tidyusda
geospatial gis r tigris usda
Last synced: 4 months ago
JSON representation
An interface to USDA Quick Stats data with mapping capabilities.
- Host: GitHub
- URL: https://github.com/bradlindblad/tidyusda
- Owner: bradlindblad
- License: other
- Created: 2019-08-25T02:46:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-26T03:07:22.000Z (over 2 years ago)
- Last Synced: 2025-12-09T13:03:02.672Z (6 months ago)
- Topics: geospatial, gis, r, tigris, usda
- Language: R
- Homepage: https://bradlindblad.github.io/tidyUSDA
- Size: 13.8 MB
- Stars: 45
- Watchers: 6
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tidyUSDA 
[](https://github.com/bradlindblad/tidyUSDA/actions)
[](https://github.com/bradlindblad/tidyUSDA/actions/workflows/pkgdown.yaml)
[](https://app.codecov.io/gh/bradlindblad/tidyusda?branch=master)
[](https://cran.r-project.org/package=tidyUSDA)
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://CRAN.R-project.org/package=tidyUSDA)
[](https://cran.r-project.org/)
**tidyUSDA**, an interface to USDA Quick Stats data with mapping capabilities.
## Overview
**tidyUSDA** provides the R user with a consistent API to pull USDA census and survey data from Quickstats.
* `getQuickstat()` lets you pass values to the fields you see on the QuickStats website, as well as include a simple features (SF) geometry field for the county or state level.
* `View({parameter name})` lets you view QuickStats all available values for a given field (which you would input into getQuickstats(), preferably with copy paste)
* `plotUSDA()` provides a quick way to plot your data if you set geometry = TRUE
## Installation
```
# Install directly from CRAN:
install.packages("tidyUSDA")
```
### Dependencies
Depending on which operating system you are installing tidyUSDA on, you may need to add external dependencies.
Please see the 'Installation' section on the [sf package homepage](https://r-spatial.github.io/sf/) for details.
## Usage
Check out the vignette with:
```
vignette("using_tidyusda")
```
You first need to grab a free API token from the USDA at their Quickstats website.
```
library(tidyUSDA)
# Save your API token to a variable, or better yet, use the keyring package to store it securely
key <- '1234-abcd'
# View all parameter names for the 'program' field
View(tidyUSDA::allProgram)
# Get count of operations with sales in 2017
ops.with.sales <- tidyUSDA::getQuickstat(
sector=NULL,
group=NULL,
commodity=NULL,
category=NULL,
domain=NULL,
county=NULL,
key = key,
program = 'CENSUS',
data_item = 'CROP TOTALS - OPERATIONS WITH SALES',
geographic_level = 'COUNTY',
year = '2017',
state = NULL,
geometry = T,
lower48 = T)
# Plot this data for each state
tidyUSDA::plotUSDA(df = ops.with.sales)
```
The last function returns this ggplot choropleth:

## Contact
* [Brad Lindblad](https://github.com/bradlindblad)
***This product uses the NASS API but is not endorsed or certified by NASS.***