An R package for automated downloading and ingestion of data from the Australian Bureau of Agricultural and Resource Economics and Sciences (ABARES).
ABARES is the research arm of the Australian federal Government Department of Agriculture, Fisheries and Forestry (DAFF). ABARES’ main role is “to provide”professionally independent data, research, analysis and advice that informs public and private decisions affecting Australian agriculture, fisheries and forestry”1.
The data provided by ABARES is extensive and varied, and includes data on agricultural production, trade, and forecasts, as well as spatial data on farm locations and top-soil thickness. ABARES data are not available from other sources but are mostly available under Creative Commons Licences for reuse.
ABARES makes several data sets freely available as spreadsheets in Microsoft Excel or CSV file formats and zip archives of geospatial data as NetCDF or shape files. {read.abares} facilitates downloading, caching and importing these files in your R session.
Data serviced include:
- the ABARES Estimates;
- the Australian Gridded Farm Data (AGFD) set;
- the Australian Agricultural and Grazing Industries Survey (AAGIS) region mapping files;
- the Historical Agricultural Forecast Database;
- the Soil Thickness for Australian areas of intensive agriculture of Layer 1 (A Horizon - top-soil) (derived from soil mapping) map and;
- the ABARES Trade
Data
including;
- the trade data and;
- the trade region data.
{read.abares} is not available through CRAN (yet). But you can install it like so:
# install.packages("pak")
pak::pak("adamhsparks/read.abares")
ABARES spreadsheet data are not always consistent in their column names
or orders. {read.abares} standardises the column names and orders and
uses snake_case for all colnames with the first letter capitalised of
every column to help you do your work more efficiently. Columns are
formatted correctly for the data type, e.g., dates are converted to
Date
class, and numbers are converted to numeric
class where
necessary, etc.
The Australian Agricultural and Grazing Industries Survey (AAGIS) region
mapping files report geometry errors that can be repaired using the
sf::st_make_valid()
function. {read.abares} automatically repairs these
geometries for you when you import the data.
{read.abares} supports caching the files using
tools::R_user_dir(package = "read.abares", which = "cache")
to save
the files in a standardised location across platforms so you don’t have
to worry about where the files went or if they’re still there. When
requesting the files {read.abares} will first check if they are
available locally either in cached or temporary storage. Caching is not
mandatory, you can just work with the downloaded files in tempdir()
,
which is cleaned up when your R session ends.
{read.abares} supports multiple classes of objects to support your workflow with the NetCDF data. Select from spatial classes for the Australian Gridded Farm Data (AGFD) NetCDF files:
- {stars},
- {terra},
- {tidync}, or if you prefer,
- a {data.table} data.frame of the whole data set.
Or for the Soil Thickness for Australian areas of intensive agriculture of Layer 1 (A Horizon - top-soil) (derived from soil mapping) data select from:
You might note that not all ABARES data are serviced by this package. The list is hand-picked to be reasonably useful and maintainable, i.e., frequently updated values are not included in this, e.g., Australian crop reports. However, if there is a data set that you feel would be useful to be serviced by {read.abares}, please feel free to open an issue with details about the data set or better yet, open a pull request!
Please report any issues or bugs.
License: MIT
Citing the data: Please refer to the ABARES website, https://www.agriculture.gov.au/abares/products/citations, on how to cite these data when you use them.
Citing {read.abares}: When citing the use of this package, please use,
library("read.abares")
citation("read.abares")
#> To cite package 'read.abares' in publications use:
#>
#> Sparks A (????). _read.abares: Simple downloading and importing of
#> ABARES Data_. R package version 1.0.0,
#> <https://adamhsparks.github.io/read.abares/>.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {{read.abares}: Simple downloading and importing of ABARES Data},
#> author = {Adam H. Sparks},
#> note = {R package version 1.0.0},
#> url = {https://adamhsparks.github.io/read.abares/},
#> }
I’ve aimed to make the testing for this package as complete as possible.
Some of the files downloaded are >1GB and may take several minutes or
more than an hour to download and due to their size, I do not wish to
include them in the package itself. If you wish to work with development
of {read.abares} please be aware that it will take some time to as the
tests use tempdir()
for tests that involve caching and it will take a
bit to establish your test environment cache.
Please note that the {read.abares} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
[^1](https://www.agriculture.gov.au/abares/about)
Footnotes
-
1 ↩