Skip to contents

About {fifo}

{fifo} is a re-imagined fork of {extractOz} that is under active development providing a unified interface to extract data from georeferenced Australian data sets using GPS points, i.e., latitude and longitude coordinates, that include all the data that the original {extractOz} supports and more:

  • Australian Agricultural and Grazing Industries Survey (AAGIS) regions via {read.abares};
  • Australian topsoil layer 1 thickness via {read.abares};
  • Grains Research and Development Corporation (GRDC) Agroecoregions via this package;
  • Australia’s Terrestrial Ecosystem Research Network (TERN) data including:
    • Soil Moisture (SMIPS) via {nert};
    • Australian Soil Class (ASC) via {nert};
  • Digital Atlas of Australian Soils via this package;
  • Queensland’s Scientific Information for Land Owners (SILO) weather data including:
    • SILO’s Data Drill 5km x 5km gridded weather data via {weatherOz};
    • SILO’s Patched Point station-based weather data via {weatherOz};
  • Your own geospatial data layer.

{fifo} is named after a work arrangement commonly used in Australian mining where an employer will temporarily transport employees to a work location or site of work, typically a mine, and transport them back for a period of rest.

Differences With {extractOz}

{fifo}

  • uses xy rather than x as the primary function argument to provide the geo-locations of interest;
  • uses locations rather than names to denote the named geo-locations of the paired lon lat values to avoid confusion with base R functionality;
  • provides access to TERN data ({extractOz} does not);
  • provides access to ABARES data ({extractOz} does not); and
  • allows direct use of data.frame, including {sf}, objects for extraction rather than requiring a list of lon and lat values;
  • has stricter checks of user-inputs that use {cli} and {rlang} for clearer and more informative messages for users about what went wrong;
  • removes the ability to crop DAAS soil order by the GRDC Agroecozones; and
  • has comprehensive test coverage, >98% of the package is covered.

Quick Start

Installation

The preferred method is to install through R-Universe like so:

# Enable this universe
options(
  repos = c(
    adamhsparks = "https://adamhsparks.r-universe.dev",
    CRAN = "https://cloud.r-project.org"
  )
)

# Install
install.packages("fifo")

Load the packages necessary to execute the examples that follow.

## Error in `library()`:
## ! there is no package called 'fifo'
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
##     filter, lag
## The following objects are masked from 'package:base':
##
##     intersect, setdiff, setequal, union

Using {fifo}

Create Locations in WA and NSW

locs <- list(
  Merredin = c(x = 118.28, y = -31.48),
  Corrigin = c(x = 117.87, y = -32.33),
  Tamworth = c(x = 150.84, y = -31.07)
)

Extract the GRDC AgroEcological Zones

See the help for extract_ae_zone for more help on how to use this function.

z <- extract_ae_zone(xy = locs)
## Error in `extract_ae_zone()`:
## ! could not find function "extract_ae_zone"

Extract the Soil Order

See the help for extract_soil_order for more help on how to use this function.

s <- extract_daas_soil_order(xy = locs)
## Error in `extract_daas_soil_order()`:
## ! could not find function "extract_daas_soil_order"

Get Weather Data for These Locations in 2020

Using the previously used list of GPS points, fetch weather data from SILO for 2020. This example uses a locally-stored API key found in the .Renviron file. See the help for extract_patched_point for more help on how to use this function.

three_sites <-
  extract_patched_point(
    xy = locs,
    start_date = "20200101",
    end_date = "20201231",
    api_key = Sys.getenv("SILO_API_KEY")
  )
## Error in `extract_patched_point()`:
## ! could not find function "extract_patched_point"

Join the Weather Data with AE Zone, Soil Order and Site Information

Now using dplyr::left_join, create a single data.frame of the location, GPS coordinates, agroecological zone and weather data.

left_join(
  z,
  three_sites,
  by = c(
    "location" = "location",
    "x" = "x",
    "y" = "y"
  )
) %>%
  left_join(s)
## Error:
## ! object 'z' not found

A Note on API Keys

The examples in this README assume that you have stored your API key(s) in your .Renviron file. See Chapter 8 in “What They Forgot to Teach You About R” by Bryan et al. for more on storing details in your .Renviron if you are unfamiliar.

Note for Linux Installers

If you are using Linux, you will likely need to install several system-level libraries. For Nectar with a fresh Ubuntu image, you can use the following command to install system libraries to install {pak} and then install {fifo}. In your Linux terminal (not your R console, the “terminal” tab in RStudio should do here in most cases) type:

sudo apt update && sudo apt install libcurl4-openssl-dev libgdal-dev gdal-bin libgeos-dev libproj-dev libsqlite3-dev libudunits2-dev libxml2-dev

Meta

Code of Conduct

Please note that the {fifo} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Contributing

Please note that the {fifo} project has a Contributing guide, please refer to it before contributing to this project.

Licensing

{fifo} is released under the GPL 3 licence. The GRDC Agroecozones geospatial data file is released under a CC-BY 4.0 International Share Alike licence.