Format and Print Coords or Waypoints
format.Rd
Format and print objects of class "coords"
or "waypoints"
.
Arguments
- x
object of class
"coords"
created by functionas_coords()
, or class"waypoints"
created by functionas_waypoints()
.- ...
further arguments passed to or from other methods.
- max
numeric or
NULL
, specifying the maximal number of entries to be printed. By default, whenNULL
,getOption("max.print")
used.- usenames
logical
, whether or not to include names in formatted output; defaultTRUE
.- aswidth
character
vector, used to match width of headers to formatted output.- fmt
integer
,1L
,2L
or3L
, specifying the required coordinate format.
Value
The format()
methods for both classes "coords"
and "waypoints"
return a
character
vector, respectively of length length(x)
or nrow(x)
, and
containing values formatted in decimal degrees, degrees and minutes, or degrees, minutes and
seconds as appropriate.
Details
The format()
methods for "coords"
and "waypoints"
objects
output elegantly formatted character
vector representations of their arguments, which are
used by their respective print()
methods.
Prior to formatting and printing, "coords"
or "waypoints"
objects are checked to
ensure that their "valid"
attribute (in the case of a "coords"
object), or
"validlat"
and "validlon"
attributes (in the case of a "waypoints"
object)
are present and all TRUE
i.e., valid. If these attributes are found to contain any
FALSE
i.e. invalid values, a warning is issued and similarly, if these attributes are
missing, a warning is issued and the objects are re-validated as described under
validate()
.
ll_headers()
outputs the headings "Latitude ... Longitude"
formatted to the
same width as argument aswidth
, adjusted for format fmt
and is primarily intended
for use by the print()
method for class "waypoints"
.
Examples
## Continuing example from `as_coords()`...
## Print named "coords" object in degrees and minutes,
## 'silently' using S3 print() method
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
## Format as a fixed-width character vector,
## with names...
format(dm)
#> [1] "Nelson's Column 51°30.4659′ N"
#> [2] "Ostravice 49°32.7726′ N"
#> [3] "Tally Ho 48°06.4339′ N"
#> [4] "Washington Monument 38°53.3696′ N"
#> [5] "Null Island 0°00.0000′ N"
#> [6] "Tristan da Cunha 37°06.7044′ S"
#> [7] "Mawson Peak 53°06.2869′ S"
#> [8] "Silvio Pettirossi International Airport 25°14.4093′ S"
#> [9] "Nelson's Column 0°07.6754′ W"
#> [10] "Ostravice 18°23.9137′ E"
#> [11] "Tally Ho 122°46.7203′ W"
#> [12] "Washington Monument 77°02.1145′ W"
#> [13] "Null Island 0°00.0000′ E"
#> [14] "Tristan da Cunha 12°17.3178′ W"
#> [15] "Mawson Peak 73°31.0370′ E"
#> [16] "Silvio Pettirossi International Airport 57°31.1536′ W"
## ...or without them
format(dm, usenames = FALSE)
#> [1] " 51°30.4659′ N" " 49°32.7726′ N" " 48°06.4339′ N" " 38°53.3696′ N"
#> [5] " 0°00.0000′ N" " 37°06.7044′ S" " 53°06.2869′ S" " 25°14.4093′ S"
#> [9] " 0°07.6754′ W" " 18°23.9137′ E" "122°46.7203′ W" " 77°02.1145′ W"
#> [13] " 0°00.0000′ E" " 12°17.3178′ W" " 73°31.0370′ E" " 57°31.1536′ W"
###
## Continuing example from `as_waypoints()`...
## Print named "waypoints" object in degrees and minutes,
## 'silently' using S3 print() method
wp
#> Latitude Longitude
#> ______________ _______________
#> Nelson's Column 51°30′27.95″ N 0°07′40.53″ W
#> Ostravice 49°32′46.36″ N 18°23′54.82″ E
#> Tally Ho 48°06′26.04″ N 122°46′43.22″ W
#> Washington Monument 38°53′22.18″ N 77°02′06.87″ W
#> Null Island 0°00′00.00″ N 0°00′00.00″ E
#> Tristan da Cunha 37°06′42.26″ S 12°17′19.07″ W
#> Mawson Peak 53°06′17.21″ S 73°31′02.22″ E
#> Silvio Pettirossi International Airport 25°14′24.56″ S 57°31′09.21″ W
## Format as a fixed-width character vector,
## with names...
format(wp)
#> [1] "Nelson's Column 51°30′27.95″ N 0°07′40.53″ W"
#> [2] "Ostravice 49°32′46.36″ N 18°23′54.82″ E"
#> [3] "Tally Ho 48°06′26.04″ N 122°46′43.22″ W"
#> [4] "Washington Monument 38°53′22.18″ N 77°02′06.87″ W"
#> [5] "Null Island 0°00′00.00″ N 0°00′00.00″ E"
#> [6] "Tristan da Cunha 37°06′42.26″ S 12°17′19.07″ W"
#> [7] "Mawson Peak 53°06′17.21″ S 73°31′02.22″ E"
#> [8] "Silvio Pettirossi International Airport 25°14′24.56″ S 57°31′09.21″ W"
## ...or without them
format(wp, usenames = FALSE)
#> [1] "Nelson's Column 51°30′27.95″ N 0°07′40.53″ W"
#> [2] "Ostravice 49°32′46.36″ N 18°23′54.82″ E"
#> [3] "Tally Ho 48°06′26.04″ N 122°46′43.22″ W"
#> [4] "Washington Monument 38°53′22.18″ N 77°02′06.87″ W"
#> [5] "Null Island 0°00′00.00″ N 0°00′00.00″ E"
#> [6] "Tristan da Cunha 37°06′42.26″ S 12°17′19.07″ W"
#> [7] "Mawson Peak 53°06′17.21″ S 73°31′02.22″ E"
#> [8] "Silvio Pettirossi International Airport 25°14′24.56″ S 57°31′09.21″ W"
rm(dm, wp)