convert | R Documentation |
Convert the format of objects of class "coords"
or "waypoints"
between (i)
decimal degrees, (ii) degrees and minutes, and (iii) degrees, minutes and seconds.
convert(x, ...)
## S3 method for class 'coords'
convert(x, fmt, ...)
## S3 method for class 'waypoints'
convert(x, fmt, ...)
x |
object of class |
... |
further arguments passed to or from other methods. |
fmt |
|
The fmt
argument should be 1L
to convert to decimal degrees, 2L
, to
convert to degrees and minutes, and 3L
to convert to degrees, minutes and
seconds. On conversion of a "coords"
object, the original argument x
is modified
to have a decimal point after the number of whole degrees in the case of decimal degrees, after
the number of whole minutes in the case of degrees and minutes, and after the number of whole
seconds in the case of degrees, minutes and seconds.
Prior to conversion, the "coords"
or "waypoints"
object to be converted is checked
to ensure its values represent valid geographic locations as described under
validate()
.
The original argument x
, an object of class "coords"
or "waypoints"
with
values converted as described under details and a revised "fmt"
attribute
reflecting the new format.
"coords"
, "waypoints"
and validate()
.
Other coordsandway:
coords
,
waypoints
## Continuing example from `as_coords()`...
## Named "coords" object in degrees and minutes with
## eight values each of latitude and longitude
dm
## Convert to degrees, minutes and seconds (fmt = 3)
convert(dm, 3)
## Convert to decimal degrees (fmt = 1)
convert(dm, 1)
## Show converted values as an ordinary R numeric vector
as.numeric(dm)
###
## Continuing example from `as_waypoints()`...
## "waypoints" object in degrees, minutes and seconds
wp
## Convert to degrees and minutes (fmt = 2)
convert(wp, 2)
## Convert to decimal degrees (fmt = 1)
convert(wp, 1)
## Show converted values as an ordinary R data frame
as.data.frame(wp)
rm(dm, wp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.