validate | R Documentation |
Validate objects of class "coords"
or "waypoints"
as geographic locations.
validate(x, ...)
## S3 method for class 'coords'
validate(x, ..., force = TRUE)
## S3 method for class 'waypoints'
validate(x, ..., force = TRUE)
x |
object of class |
... |
further arguments passed to or from other methods. |
force |
|
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
.
validate()
returns its argument with logical
vector attribute "valid"
,
or attributes "validlat"
and "validlon"
updated as appropriate for
"coords"
and' "waypoints"
objects respectively.
"coords"
and "waypoints"
.
Other validate:
review()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.