
Last chance! 50% off unlimited learning
Sale ends in
Expand a table of location samples to location pairs.
gc_endpoints(data, lon, lat, distance = TRUE, keep = TRUE)
a data frame.
character, the column in data
referring to longitudes.
character, the column in data
referring to latitudes.
logical, include a column of distances between locations along the shorter arc of the implied great circle. Defaults to TRUE
.
logical, retain copies of other columns in data
if data
contained more than longitude and latitude columns. Defaults to TRUE
.
a data frame.
gc_endpoints
expands a data frame of with longitude and latitude coordinate columns into one with four columns of lon0
, lat0
, lon1
and lat1
representing pairs of locations.
This is done in preparation for generating great circle arcs between each pair of locations. gc_endpoints
provides the endpoints of these arcs.
See gc_lines
, which is used subsequently on output from gc_endpoints
, to generate an expanded data frame of the corresponding great circle ars.
gc_endpoints
merely splits a data frame into its first and second halves of rows and then expands a table that has rows for every combination of pairs between the first and second halves of the original table.
This is a handy utility function for preparing data for simulated examples of network maps in the current version of mapmate
.
In future versions a more robust gc_endpoints
may offer other more controllable options for assembling location pairs.
When keep=TRUE
columns in data
other than those of longitudes and latitudes are similarly appended with 0
and 1
in the output,
corresponding to the columns lon0/lat0
and to lon1/lat1
, respectively.
If data
contains n
rows, then the data frame returned by gc_endpoints
will contain
# NOT RUN {
library(dplyr)
data(network)
gc_endpoints(network, "lon", "lat")
gc_endpoints(network, "lon", "lat", distance=FALSE)
gc_endpoints(network, "lon", "lat", keep=FALSE)
# }
Run the code above in your browser using DataLab