parse_record: Calculate flags for a single record

View source: R/parse_record.R

parse_recordR Documentation

Calculate flags for a single record

Description

parse_record calls the GET method of the API in order to extract the flags for an individual record. It returns just the flags element.

Usage

parse_record(record = NULL, decimalLatitude = NULL,
  decimalLongitude = NULL, countryCode = NULL, scientificName = NULL, ...)

Arguments

record

List-type object containing information on the record. If present, it MUST contain the following four attributes as named elements.

decimalLatitude

Only if 'record' is not present. Latitude in decimal degrees format (float, e.g. 42.1833)

decimalLongitude

Only if 'record' is not present. Longitude in decimal degrees format (float, e.g. -1.8332)

countryCode

Only if 'record' is not present. Two or three-letter ISO-3166 country codes (string, e.g. "ES")

scientificName

Only if 'record' is not present. Binomial identifying the species (string, e.g. "Puma concolor")

...

Any extra parameters for httr GET

Details

Data can be passed in two different ways to this function: either with the four key elements (decimalLatitude, decimalLongitude, countryCode and scientificName) passed as named arguments or via a single record parameter that consists of a list with these four elements. However, if both are filled, the function will stop and show an error message. The more filled fields, the more informative the output of the API will be. However, due to the flexible nature of the underlying API, a valid response will be get even if no input data is provided. Therefore, calling parse_record() with no arguments will return a list of three FALSE elements, which represents no information at all. The function will however throw a warning for each missing field. See flags for more info on the input and output of the function.

Value

A named list with the geospatial quality flags

See Also

flags, add_flags

Examples

## Not run: 
# Using the 'record' parameter
# Create 'record' object with values
rec <- list(decimalLatitude=42.1833, decimalLongitude=-1.8332,
            countryCode="ES", scientificName="Puma concolor")
# Call the API and get the results
parse_record(record=rec)

# Using named arguments
parse_record(decimalLatitude=42.1833, decimalLongitude=-1.8332,
           countryCode="ES", scientificName="Puma concolor")
# In both cases, the result will be the same

# If any parameter is missing, the function runs, but throws a warning
# message. This will throw a warning saying that 'countryCode' and
# 'scientificName' fields are missing. Also, the results will be
# limited to the feasible calculations.
parse_record(decimalLatitude=42.1833, decimalLongitude=-1.8332)

# One can call the function without parameters. Although valid,
# this way of calling the function is useless.
parse_record()

## End(Not run)

ropenscilabs/rgeospatialquality documentation built on May 18, 2022, 7:42 p.m.