Skip to contents

This function finds the closest locality to the given point location, as well as its distance and direction from the focal location. The returned string could be used in the Darwin Core locality field.

Usage

dwc_locality(
  decimalLongitude,
  decimalLatitude,
  localities_sf,
  localities_names,
  ...
)

Arguments

decimalLongitude

The longitude of the focal point in decimal degrees. Output of dwc_coordinates. See: http://rs.tdwg.org/dwc/terms/decimalLongitude.

decimalLatitude

The latitude of the focal point in decimal degrees. Output of dwc_coordinates. See: http://rs.tdwg.org/dwc/terms/decimalLatitude.

localities_sf

An sf POINT object that provides locality names as well as their longitude and latitude for all localities within the area of interest. The package includes the locality information for Australia. See locality_data_aus

localities_names

The column name in localities_sf that gives the locality name.

...

Additional arguments passed to st_distance

Value

A string that could be used in the Darwin Core locality field, http://rs.tdwg.org/dwc/terms/locality.

Examples

localities_sf <-
  sf::st_as_sf(
    data.frame(
      name = c("A", "B", "C"),
      lon = c(117.093225, 127.502052, 115.674972),
      lat = c(-33.110168, -25.128663, -33.982473)
    ),
    coords = c("lon", "lat"),
    crs = sf::st_crs("EPSG:4326")
  )


dwc_locality(
  decimalLongitude = 115.949465,
  decimalLatitude = -32.029655,
  localities_sf = localities_sf,
  localities_names = "name"
)
#> [1] "161 km SE A"