set_coordinates: Set, create or modify columns with spatial information

View source: R/set_coordinates.R

set_coordinatesR Documentation

Set, create or modify columns with spatial information

Description

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.

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

Value

A tibble with the requested columns added/reformatted.

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
    )


corella documentation built on April 4, 2025, 12:20 a.m.