uniqueCoord: Flag Duplicated Coordinates

View source: R/uniqueCoord.R

uniqueCoordR Documentation

Flag Duplicated Coordinates

Description

Flag Duplicated Coordinates

Usage

uniqueCoord(
  x,
  lon = "decimalLongitude.new",
  lat = "decimalLatitude.new",
  tax.name = "scientificName.new",
  type = c("exact", "dist"),
  output = "group",
  min.dist = 0.001
)

Arguments

x

Data frame with geographical coordinates

lon

character. Column with the record longitude in decimal degrees

lat

character. Column with the record latitude in decimal degrees

tax.name

character. Name of the columns containing the species name. Default to "scientificName.new"

type

character. Type of approach to search for duplicated coordinates.

output

character. Type of output desired: 'group' and/or 'flag'.

min.dist

numerical. Minimum threshold distance (in kilometers) to be used to detect duplicated coordinates.

Details

If type is 'exact', only coordinates with the exact same coordinates are flagged. If type is 'dist', coordinates below the minimum threshold distance defined by min.dist are flagged. If both methods are selected, the function returns the results for both approaches.

If output is 'group' (the default), the column returned contains the suffix '.ID' and it stores a number that can be used as a species-specific ID to group duplicated coordinates. If output is 'flag', then a TRUE/FALSE vector is returned indicating which coordinates are duplicated within each species. If both are selected, then both are returned. Note that the ID numbers for each of the approaches ('exact' and 'dist') are not related.

If no column containing the species names is provided, the function assumes that all coordinates belong to the same species, with a warning.

The argument min.dist 0.001 km (1 meter) is by default and not zero, because the precision of geographical coordinates are often above 1 meter. In practice, a min.dist of 0.0001 or lower should return the same output as the exact approach.

Value

the input data frame and the new columns with the results from the 'exact' and/or 'minimum distance' approaches to flag duplicated coordinates.

Author(s)

Renato A. Ferreira de Lima

See Also

geoDist and minDist.

Examples

coords <- data.frame(
lat = c(-23.475389, -23.475389, -23.475390, -23.485389,
        -23.575389, -23.575389, -23.575390, -23.485389),
lon = c(-47.123768, -47.123768, -47.123768, -47.113768,
        -47.223768, -47.223768, -47.223768, -47.113768))
## Not run: 
uniqueCoord(coords, lon = "lon", lat = "lat")
uniqueCoord(coords, lon = "lon", lat = "lat", type = "dist")
uniqueCoord(coords, lon = "lon", lat = "lat", min.dist = 0.0001)
uniqueCoord(coords, lon = "lon", lat = "lat", output = "flag")

## End(Not run)


LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.