validate: Validate Coords or Waypoints

View source: R/CoordBase.R

validateR Documentation

Validate Coords or Waypoints

Description

Validate objects of class "coords" or "waypoints" as geographic locations.

Usage

validate(x, ...)

## S3 method for class 'coords'
validate(x, ..., force = TRUE)

## S3 method for class 'waypoints'
validate(x, ..., force = TRUE)

Arguments

x

object of class "coords" created by function as_coords(), or class "waypoints" created by function as_waypoints().

...

further arguments passed to or from other methods.

force

logical signifying whether, if TRUE, to perform full de novo revalidation or, if FALSE, simply check existing "valid" attribute in the case of a "coords" object, or "validlat" and "validlon" attributes in the case of a "waypoints" object and only revalidate if any of these are missing; default TRUE.

Details

Individual coordinate values within "coords" or "waypoints" objects are checked to ensure they represent valid geographic locations.

To be valid, the absolute values of coordinates in degrees must not exceed 180°, or 90° if degrees of latitude and, similarly, the absolute values of the minutes and seconds components, where given, must not exceed 60. Otherwise, a warning will be issued and the "valid" attribute in the case of a "coords" object, or "validlat" and "validlon" attributes in the case of a "waypoints" object will be set to FALSE for any non-compliant coordinate values.

Argument force is primarily intended for use by the print() methods for classes "coords" and "waypoints" and should otherwise left as the default value TRUE.

Value

validate() returns its argument with logical vector attribute "valid", or attributes "validlat" and "validlon" updated as appropriate for "coords" and' "waypoints" objects respectively.

See Also

"coords" and "waypoints".

Other validate: review()

Examples

## Continuing example from `as_coords()`...


## Validate "coords" object in degrees and minutes
validate(dm)

## Deliberately change the first coordinate
## to a value greater than 60 minutes
dm[1] <- 5160.4659

validate(dm)

## Examine "valid" attribute of dm
attr(dm, "valid")

###
## Continuing second example from `as_waypoints()`...


## Validate "waypoints" object in decimal degrees

validate(wp)

## Deliberately change the penultimate latitude
## to an absolute value greater than 90 degrees
wp$lat[7] <- -93.104781

validate(wp)

## Examine "validlat" attribute of wp
attr(wp, "validlat")

rm(dm, wp)


Waypoint documentation built on April 11, 2025, 6:12 p.m.