coords | R Documentation |
as_coords()
creates an object of class "coords"
, a robust representation of a
series of geographic or GPS coordinate values.
latlon()<-
adds information to objects of class "coords"
specifying whether
individual coordinate values represent latitude or longitude.
as_coords(object, ...)
## Default S3 method:
as_coords(object, ..., fmt = 1L)
latlon(cd) <- value
## S3 method for class 'waypoints'
as_coords(object, which, ...)
object |
a |
... |
further arguments passed to or from other methods. |
fmt |
|
cd |
object of class |
value |
a |
which |
|
Individual values provided in a numeric
vector argument object
should 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.
The fmt
argument should be 1L
to represent decimal degrees, 2L
for degrees
and minutes, and 3L
for degrees, minutes and seconds and is used to provide the
format of values in the numeric
vector argument object
to be converted to class
"coords"
.
The values of a newly created "coords"
object are checked to ensure they are valid
geographic locations as described under validate()
.
Individual coordinate values in a Coords
object may be specified as representing latitude
or longitude using latlon()
. The value
argument may either be a single value,
TRUE
signifying that all values are latitude, FALSE
signifying that all values are
longitude, or a logical
vector of the same length as as the Coords
object signifying
whether individual values are latitude or longitude.
as_cords()
returns an object of class "coords"
, comprising a numeric
vector
argument with additional attributes: –
"class" |
the |
"fmt" |
an |
"valid" |
a |
The as_cords()
method for class "coords"
returns its numeric
vector argument
object
modified in place, whereas the method for class 'waypoints' returns a new
numeric
vector.
latlon()
returns its "coords"
argument cd
with a logical
vector
attribute "latlon"
added or updated to reflect argument value
.
attr()
, attributes
, and
validate()
.
Other coordsandway:
convert()
,
waypoints
## Numeric vector representing degrees and minutes, with
## the decimal point after the number of whole minutes
dm <- c(5130.4659, 4932.7726, 4806.4339, 3853.3696, 0.0000, -3706.7044, -5306.2869, -2514.4093,
-007.6754, 1823.9137, -12246.7203, -7702.1145, 0.0000, -1217.3178, 7331.0370, -5731.1536)
## Create an unnamed "coords" object in degrees and minutes (fmt = 2)
## (Latitude and longitude unspecified)
as_coords(dm, fmt = 2)
## Name the "coords" object
names(dm) <- rep(c("Nelson's Column", "Ostravice", "Tally Ho", "Washington Monument", "Null Island",
"Tristan da Cunha", "Mawson Peak", "Silvio Pettirossi International Airport"), 2)
dm
## Set all values to represent longitude
## ("latlon" attribute set to FALSE, length 1)
latlon(dm) <- FALSE
dm
## Set eight values each of latitude and longitude
## ("latlon" attribute set to TRUE, n=8, and FALSE, n=8)
latlon(dm) <- rep(c(TRUE, FALSE), each = 8)
dm
## Show as an ordinary R numeric vector
as.numeric(dm)
rm(dm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.