
Extract Australian Soil Class data from TERN's API using Australian GPS coordinates
Source:R/extract_asc.R
extract_asc.RdExtracts the Australian Soil Class data at the GPS points provided, assuming that they are land-based coordinates in Australia from the Australian Soil Class (ASC). Values for the Confusion Index, the amount of model certainty around the soil class at that grid cell, are also supported.
Usage
extract_asc(
xy,
locations = NULL,
lonlat = NULL,
confusion_index = FALSE,
api_key = nert::get_key(),
max_tries = 3L,
initial_delay = 1L
)Arguments
- xy
A
listordata.frameobject with names containing pairings of longitude and latitude values expressed as decimal degree values in that order. Adata.framemay also be an sf points object. See Details for more.- locations
The column in which the location names are located as an
Integervalue. Defaults to1.- lonlat
A
vectorofintegervalues indicating the column index in which the longitude and latitude values are contained. Defaults to2:3.- confusion_index
Boolean, extract the values for the Confusion Index with the soil class? Defaults toFALSEand returns the soil class data only.- api_key
A
characterstring containing your API key, a random string provided to you by TERN, for the request. Defaults to automatically detecting your key from your local .Renviron, .Rprofile or similar. Alternatively, you may directly provide your key as a string here or use functionality like that from keyring. If nothing is provided, you will be prompted on how to set up your R session so that it is auto-detected and a browser window will open at the TERN website for you to request a key.- max_tries
An integer
Integerwith the number of times to retry a failed download before emitting an error message. Defaults to3.- initial_delay
An
Integerwith the number of seconds to delay before retrying the download. This increases as the tries increment. Defaults to1.
Value
A data.table::data.table() with the provided GPS
coordinates and the respective Australian Soil Class for the coordinates
from the ASC data ("asc_longitude" and "asc_latitude").
xy
xy as a List Object
If xy is a list object, each individual vector's items should be named
“x” (longitude) and “y” (latitude), respectively. The list
item names should be descriptive of the individual vectors and will be
included in a “location” column of the output.
xy as a Data Frame Object
If xy is a data.frame, it should be a three column object with the first
column being the location name, the second longitude and the third,
latitude both as decimal degrees in numeric format.
xy as an sf Object
If xy is an sf object, it should only be point geometry. If the
data are projected, they will be reprojected to "EPSG:4326", Geographic
Coordinate System WGS 84 before the extraction.
Examples
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_asc(xy = locs, confusion_index = TRUE)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'y' in selecting a method for function 'extract': undefined columns selected