Skip to contents

This function helps format standard location fields like latitude and longitude point coordinates to a tibble using Darwin Core Standard.

Usage

set_coordinates(
  .df,
  decimalLatitude = NULL,
  decimalLongitude = NULL,
  geodeticDatum = NULL,
  coordinateUncertaintyInMeters = NULL,
  coordinatePrecision = NULL,
  .keep = "unused"
)

Arguments

.df

A data.frame or tibble that the column should be appended to.

decimalLatitude

The latitude in decimal degrees.

decimalLongitude

The longitude in decimal degrees.

geodeticDatum

The datum or spatial reference system that coordinates are recorded against (usually "WGS84" or "EPSG:4326"). This is often known as the Coordinate Reference System (CRS). If your coordinates are from a GPS system, your data are already using WGS84.

coordinateUncertaintyInMeters

(numeric) Radius of the smallest circle that contains the whole location, given any possible measurement error. coordinateUncertaintyInMeters will typically be around 30 (metres) if recorded with a GPS after 2000, or 100 before that year.

coordinatePrecision

(numeric) The precision that decimalLatitude and decimalLongitude are supplied to. coordinatePrecision should be no less than 0.00001 if data were collected using GPS.

.keep

Control which columns from .df are retained in the output. Note that unlike dplyr::mutate(), which defaults to "all" this defaults to "unused"; i.e. only keeps Darwin Core columns, and not those columns used to generate them.

Value

A tibble with the requested columns added/reformatted.

Details

In practice this is no different from using mutate(), but gives some informative errors, and serves as a useful lookup for how spatial columns are represented in the Darwin Core Standard.

Example values are:

  • geodeticDatum should be a valid EPSG code

See also

set_locality() for provided text-based spatial information.

Examples

df <- tibble::tibble(
  scientificName = c("Crinia Signifera", "Crinia Signifera", "Litoria peronii"),
  latitude = c(-35.27, -35.24, -35.83),
  longitude = c(149.33, 149.34, 149.34),
  eventDate = c("2010-10-14", "2010-10-14", "2010-10-14")
  )

# Reformat columns to Darwin Core Standard terms
df |>
  set_coordinates(
    decimalLongitude = longitude,
    decimalLatitude = latitude
    )
#> ⠙ Checking 2 columns: decimalLatitude and decimalLongitude
#>  Checking 2 columns: decimalLatitude and decimalLongitude [617ms]
#> 
#> # A tibble: 3 × 4
#>   scientificName   eventDate  decimalLatitude decimalLongitude
#>   <chr>            <chr>                <dbl>            <dbl>
#> 1 Crinia Signifera 2010-10-14           -35.3             149.
#> 2 Crinia Signifera 2010-10-14           -35.2             149.
#> 3 Litoria peronii  2010-10-14           -35.8             149.