Title: | A Minimal Tool Set for Gathering USDA Quick Stat Data for Analysis and Visualization |
---|---|
Description: | Provides a consistent API to pull United States Department of Agriculture census and survey data from the National Agricultural Statistics Service (NASS) QuickStats service. |
Authors: | Brad Lindblad [aut, cre], Michael Thomas [ctb], Alex Mindeman [ctb] |
Maintainer: | Brad Lindblad <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1.9000 |
Built: | 2024-12-31 05:33:57 UTC |
Source: | https://github.com/bradlindblad/tidyusda |
All possible values from the CATEGORY field.
allCategory
allCategory
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the COMMODITY field.
allCommodity
allCommodity
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the COUNTY field.
allCounty
allCounty
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the DATA ITEM field.
allDataItem
allDataItem
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the DOMAIN field.
allDomain
allDomain
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the GEOGRAPHY LEVEL field.
allGeogLevel
allGeogLevel
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the GROUP field.
allGroup
allGroup
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the PROGRAM field.
allProgram
allProgram
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the SECTOR field.
allSector
allSector
A vector with 1 variable
https://quickstats.nass.usda.gov
All possible values from the STATE field.
allState
allState
A vector with 1 variable
https://quickstats.nass.usda.gov
Get values from USDA Quick Stats in a dataframe with optional sf (simple features) geometry field
getQuickstat( key = NULL, program = NULL, data_item = NULL, sector = NULL, group = NULL, commodity = NULL, category = NULL, domain = NULL, geographic_level = NULL, state = NULL, county = NULL, year = NULL, geometry = FALSE, lower48 = FALSE, weighted_by_area = FALSE )
getQuickstat( key = NULL, program = NULL, data_item = NULL, sector = NULL, group = NULL, commodity = NULL, category = NULL, domain = NULL, geographic_level = NULL, state = NULL, county = NULL, year = NULL, geometry = FALSE, lower48 = FALSE, weighted_by_area = FALSE )
key |
your USDA api key. Get one at https://quickstats.nass.usda.gov/api - string |
program |
program field - string |
data_item |
data_item field - string |
sector |
sector field - string |
group |
group field - string |
commodity |
commodity field - string |
category |
category field - string |
domain |
domain field - string |
geographic_level |
geographic_level field - string |
state |
state field - either a string or character vector with multiple states |
county |
county field - either a string or character vector with multiple states |
year |
year field - string |
geometry |
geometry field (TRUE or FALSE), set to TRUE if you would like a simple features (SF) geometry field included. Only works when geographic_level is set to 'COUNTY' or 'STATE' |
lower48 |
limit data to the lower 48 states? - TRUE or FALSE |
weighted_by_area |
option to mutate a new column that takes the target ('Value') and divides it by the square miles in that state or county; only works when GEOMETRY = TRUE - TRUE or FALSE |
Go to the webpage https://quickstats.nass.usda.gov/. As a best practice, select the items in these fields and test that that data item exists in the browser before using those parameters in this function. When you have a dataset that works, enter those values in the function as parameters. Ideally, only enter values for your key obviously, then PROGRAM, DATA_ITEM, GEOGRAPHIC_LEVEL and then if necessary, DOMAIN, STATE, COUNTY or YEAR.
## Not run: getQuickstat( key = "your_key", program = "CENSUS", data_item = "CROP TOTALS - OPERATIONS WITH SALES", geographic_level = "COUNTY", domain = "TOTAL", year = "2017", state = NULL, geometry = T, lower48 = T ) ## End(Not run)
## Not run: getQuickstat( key = "your_key", program = "CENSUS", data_item = "CROP TOTALS - OPERATIONS WITH SALES", geographic_level = "COUNTY", domain = "TOTAL", year = "2017", state = NULL, geometry = T, lower48 = T ) ## End(Not run)
Quickly plot a data frame produced by the getQuickstat() function.
plotUSDA(df, fill_by = "Value")
plotUSDA(df, fill_by = "Value")
df |
a data frame with a simple feature column (geometry) |
fill_by |
the value you would like to fill your choropleth output |
## Not run: # Use output from getQuickstat() plotUSDA(df = df_from_getQuickstat) ## End(Not run)
## Not run: # Use output from getQuickstat() plotUSDA(df = df_from_getQuickstat) ## End(Not run)
A minimal toolset for gathering USDA Quick Stat data for analysis and visualization.
Maintainer: Brad Lindblad [email protected]
Other contributors:
Michael Thomas [email protected] [contributor]
Alex Mindeman [email protected] [contributor]
Useful links: