Geographic or GPS Coordinate
coord.Rd
Geographic or GPS coordinate class
Arguments
- x
numeric
, representing one or more coordinates.- .fmt
character
string indicating the format ofx
; must be one of"decdeg"
(default),"degmin"
or"degminsec"
.- .latorlon
a
character
string, either"lat"
or"lon"
indicating whether the coordinate(s) represented are of latitude or longitude or"both"
indicating a pair of of latitude and longitude coordinates; otherwise it must beNA
(the default).
Value
An object of class "coord"
or if length(x) > 1
, a list of such objects, each
instantiating a coordinate. See Details.
Details
coord()
creates a robust representation of a geographic or GPS cordinate based on the value of
x
or, if length(x) > 1
, a number of such coordinates instatiated as objects of class
"coord"
. Objects of "coord"
class contain a list
with one, two or three numeric
values
named "deg"
, "min"
, "sec"
, depending on whether the cordinate in question is represented
in decimal degrees, in (integer) degrees and (decimal) minutes, or else in (integer) degrees,
(integer) minutes, and (decimal) seconds.
The value provided in argument x
should have a decimal point after the integer number
of degrees in the case of decimal degrees, after the integer number of minutes in the case of
degrees and minutes, and after the integer number of seconds in the case of degrees, minutes and
seconds
"coord"
objects have character
attribute latorlon
, which may be "lat"
for latitude,
"lon"
for longitude or NA
, and a logical
attribute "negative"
, which when TRUE
signifies a negative coordinate i.e., S or W rather than N or E.
If length(x) > 1
, a list of "coord"
objects is returned, all of which will have the same
latorlon
attribute (i.e., either all 'lat"
or all "lon"
). The exception is the case in
which argument .latorlon
is both
and length(x) = 2
, when a list of two "coord"
objects
is returned, having latorlon
attributes one each of "lat"
and "lon"
; the list itself is an
object of class "latnlon"
.
The total value in degrees, minutes and seconds may not be greater than 180˚
, while the
minutes and seconds components (if present) must be less than 60˚
. If latitude is
represented, (i.e., latorlon
attribute is "lat"
), its maximum absolute value is 90˚
.
See also
Other coord:
as_degminsec()
Examples
## Decimal degrees (default)
coord(51.507765)
#> 51.507765°
coord(-0.127924)
#> -0.127924°
coord(51.507765,, "lat")
#> 51.507765° lat
coord(-0.127924,, "lon")
#> -0.127924° lon
coord(c(51.507765, -0.127924),, "both")
#> 51.507765° lat -0.127924° lon
c(51.507765, 49.546210, 48.107232, 38.889494, 0.000000, -37.111740, -53.104781) |>
coord(, "lat")
#> [[1]]
#> 51.507765° lat
#> [[2]]
#> 49.546210° lat
#> [[3]]
#> 48.107232° lat
#> [[4]]
#> 38.889494° lat
#> [[5]]
#> 0.000000° lat
#> [[6]]
#> -37.111740° lat
#> [[7]]
#> -53.104781° lat
c(-0.127924, 18.398562, -122.778671, -77.035242, 0.000000, -12.28863, 73.517283) |>
coord(, "lon")
#> [[1]]
#> -0.127924° lon
#> [[2]]
#> 18.398562° lon
#> [[3]]
#> -122.778671° lon
#> [[4]]
#> -77.035242° lon
#> [[5]]
#> 0.000000° lon
#> [[6]]
#> -12.288630° lon
#> [[7]]
#> 73.517283° lon
## Degrees and minutes
coord(5130.4659, "degmin")
#> 51°30.4659' (N/E)
coord(-7.6754, "degmin")
#> 0°07.6754' (W/S)
coord(5130.4659, "degmin", "lat")
#> 51°30.4659' N
coord(-7.6754, "degmin", "lon")
#> 0°07.6754' W
coord(c(5130.4659, -7.6754), "degmin", "both")
#> 51°30.4659' N 0°07.6754' W
c(5130.4659, 4932.7726, 4806.4339, 3853.3696, 0.0000, -3706.7044, -5306.2869) |>
coord("degmin", "lat")
#> [[1]]
#> 51°30.4659' N
#> [[2]]
#> 49°32.7726' N
#> [[3]]
#> 48°06.4339' N
#> [[4]]
#> 38°53.3696' N
#> [[5]]
#> 0°00.0000' N
#> [[6]]
#> 37°06.7044' S
#> [[7]]
#> 53°06.2869' S
c(-7.6754, 1823.9137, -12246.7203, -7702.1145, 0.0000, -1217.3178, 7331.0370) |>
coord("degmin", "lon")
#> [[1]]
#> 0°07.6754' W
#> [[2]]
#> 18°23.9137' E
#> [[3]]
#> 122°46.7203' W
#> [[4]]
#> 77°02.1145' W
#> [[5]]
#> 0°00.0000' E
#> [[6]]
#> 12°17.3178' W
#> [[7]]
#> 73°31.0370' E
## Degrees, minutes and seconds
coord(513027.95, "degminsec")
#> 51°30'27.95" (N/E)
coord(-740.53, "degminsec")
#> 0°07'40.53" (W/S)
coord(513027.95, "degminsec", "lat")
#> 51°30'27.95" N
coord(-740.53, "degminsec", "lon")
#> 0°07'40.53" W
coord(c(513027.95, -740.53), "degminsec", "both")
#> 51°30'27.95" N 0°07'40.53" W
c(513027.95, 493246.36, 480626.04, 385322.18, 0.00, -370642.26, -530617.21) |>
coord("degminsec", "lat")
#> [[1]]
#> 51°30'27.95" N
#> [[2]]
#> 49°32'46.36" N
#> [[3]]
#> 48°06'26.04" N
#> [[4]]
#> 38°53'22.18" N
#> [[5]]
#> 0°00'00.00" N
#> [[6]]
#> 37°06'42.26" S
#> [[7]]
#> 53°06'17.21" S
c(-740.53, 182354.82, -1224643.22, -770206.87, 0.00, -121719.07, 733102.22) |>
coord("degminsec", "lon")
#> [[1]]
#> 0°07'40.53" W
#> [[2]]
#> 18°23'54.82" E
#> [[3]]
#> 122°46'43.22" W
#> [[4]]
#> 77°02'06.87" W
#> [[5]]
#> 0°00'00.00" E
#> [[6]]
#> 12°17'19.07" W
#> [[7]]
#> 73°31'02.22" E