flipSign {rangeBuilder}R Documentation

Flip sign of coordinates

Description

Checks for coordinate sign mistakes by checking all possibilities against country occupancy.

Usage

flipSign(
  coordVec,
  country,
  returnMultiple = FALSE,
  filterByLand = TRUE,
  crs = 4326
)

Arguments

coordVec

numeric vector of length 2: longitude, latitude

country

the country that is associated with the record

returnMultiple

if multiple sign flips lead to the correct country, return all options. If FALSE, returns the coords with the fewest needed sign flips.

filterByLand

if TRUE, alternative coords will be tested for whether or not they fall on land.

crs

the crs of the coordinate.

Details

This function generates all possible coordinates with different signs, and runs closestCountry on each, returning the coordinates that lead to a country match. It ignores coordinate options that do not pass filterByLand.

If a point falls close to the boundary between two countries, it is still considered a match.

Value

list with 2 elements

matched

logical: Was the country matched

newcoords

matrix of coordinates that were successful.

Author(s)

Pascal Title

Examples


#correct coordinates
flipSign(c(4.28, 39.98), country = 'Spain')

#mistake in coordinate sign
flipSign(c(115.436, 32.657), country = 'United States')

#incorrect sign on both long and lat, but not possible to distinguish for longitude
#except when we consider which alternative coords fall on land.
flipSign(c(-4.28, -39.98), country = 'Spain', filterByLand = FALSE, returnMultiple = TRUE)
flipSign(c(-4.28, -39.98), country = 'Spain', returnMultiple = TRUE)

#coordinates are incorrect
flipSign(c(4.28, 59.98), country = 'Spain')


[Package rangeBuilder version 2.1 Index]