Latitude or Longitude Attribute for Coords
latlon.Rd
latlon()<-
adds the attribute "latlon"
to objects of class
"coords"
, or modifies an existing "latlon"
attribute.
Arguments
- cd
object of class
"coords"
.- value
a
logical
vector of length1
orlength(cd)
.
Details
Attribute "latlon"
is a logical
vector of length 1
or length(cd)
for which TRUE
values represent latitude and FALSE
values represent longitude.
Setting this attribute to any other length will result in an error. A logical
vector of
length 1L
signifies that values are all latitude if TRUE
, or all longitude if
FALSE
.
This attribute is used in formatting printed output and also by
validate()
. Indeed, the values of cd
are revalidated every time
attribute "latlon"
is added or changed.
See also
"coords"
.
Examples
## Continuing example from `coords()`...
## Create "coords" object in degrees and minutes
as_coords(dm, fmt = 2)
#> Nelson's Column 51°30.4659′ (N/E)
#> Ostravice 49°32.7726′ (N/E)
#> Tally Ho 48°06.4339′ (N/E)
#> Washington Monument 38°53.3696′ (N/E)
#> Null Island 0°00.0000′ (N/E)
#> Tristan da Cunha 37°06.7044′ (S/W)
#> Mawson Peak 53°06.2869′ (S/W)
#> Silvio Pettirossi International Airport 25°14.4093′ (S/W)
#> Nelson's Column 0°07.6754′ (S/W)
#> Ostravice 18°23.9137′ (N/E)
#> Tally Ho 122°46.7203′ (S/W)
#> Washington Monument 77°02.1145′ (S/W)
#> Null Island 0°00.0000′ (N/E)
#> Tristan da Cunha 12°17.3178′ (S/W)
#> Mawson Peak 73°31.0370′ (N/E)
#> Silvio Pettirossi International Airport 57°31.1536′ (S/W)
## Set "latlon" attribute to FALSE, length 1; all values are longitude
latlon(dm) <- FALSE
dm
#> Nelson's Column 51°30.4659′ E
#> Ostravice 49°32.7726′ E
#> Tally Ho 48°06.4339′ E
#> Washington Monument 38°53.3696′ E
#> Null Island 0°00.0000′ E
#> Tristan da Cunha 37°06.7044′ W
#> Mawson Peak 53°06.2869′ W
#> Silvio Pettirossi International Airport 25°14.4093′ W
#> Nelson's Column 0°07.6754′ W
#> Ostravice 18°23.9137′ E
#> Tally Ho 122°46.7203′ W
#> Washington Monument 77°02.1145′ W
#> Null Island 0°00.0000′ E
#> Tristan da Cunha 12°17.3178′ W
#> Mawson Peak 73°31.0370′ E
#> Silvio Pettirossi International Airport 57°31.1536′ W
## Set "latlon" attribute to TRUE (n=8) and FALSE (n=8)
## i.e., 8 each of latitude and longitude
latlon(dm) <- rep(c(TRUE, FALSE), each = 8)
dm
#> Nelson's Column 51°30.4659′ N
#> Ostravice 49°32.7726′ N
#> Tally Ho 48°06.4339′ N
#> Washington Monument 38°53.3696′ N
#> Null Island 0°00.0000′ N
#> Tristan da Cunha 37°06.7044′ S
#> Mawson Peak 53°06.2869′ S
#> Silvio Pettirossi International Airport 25°14.4093′ S
#> Nelson's Column 0°07.6754′ W
#> Ostravice 18°23.9137′ E
#> Tally Ho 122°46.7203′ W
#> Washington Monument 77°02.1145′ W
#> Null Island 0°00.0000′ E
#> Tristan da Cunha 12°17.3178′ W
#> Mawson Peak 73°31.0370′ E
#> Silvio Pettirossi International Airport 57°31.1536′ W
## Reversing latitude and longitude results in an invalid latitude,
## throwing a warning
latlon(dm) <- rep(c(FALSE, TRUE), each = 8)
#> Warning: Validation failed!
dm
#> Warning: Formatting invalid coords!
#> Nelson's Column 51°30.4659′ E
#> Ostravice 49°32.7726′ E
#> Tally Ho 48°06.4339′ E
#> Washington Monument 38°53.3696′ E
#> Null Island 0°00.0000′ E
#> Tristan da Cunha 37°06.7044′ W
#> Mawson Peak 53°06.2869′ W
#> Silvio Pettirossi International Airport 25°14.4093′ W
#> Nelson's Column 0°07.6754′ S
#> Ostravice 18°23.9137′ N
#> Tally Ho 122°46.7203′ S
#> Washington Monument 77°02.1145′ S
#> Null Island 0°00.0000′ N
#> Tristan da Cunha 12°17.3178′ S
#> Mawson Peak 73°31.0370′ N
#> Silvio Pettirossi International Airport 57°31.1536′ S
rm(dm)