Expand a table of great circle arcs to a larger table of great circle arc segments that sequentially traverse the original arcs.

gc_paths(data, group, size, replicates = 1, direction = "fixed",
  max.offset = 0)

Arguments

data

a data frame.

group

character, the column in data referring to the grouping variable.

size

integer, the maximum number of points used to define a great circle arc segment.

replicates

integer, the number of replicates of an arc. Defaults to 1.

direction

character. Defaults to fixed.

max.offset

integer, maximum allowable offset for the plot frame on which great circle arc path traversal commences.

Value

a data frame.

Details

gc_paths takes a data frame as generated by gc_arcs and breaks each set of points defining each arc into a sequence of points defining arc segments that cover the entire original arc in order from one endpoint to the other. Segments along the path that covers an arc may overlap to varying degrees based on the segment size, which is variable.

group keeps different network pathways distinct within each plot frame when multiple great circle arcs are traversed simultaneously.

size describes the maximum number of points composing a great circle arc segment. It must be at least 2 and is used to sample integers uniformly between \([2, size]\). This defines the range of values from which the actual segment length is sampled. There are not any other options in the current package version for specifying segment lengths. Length is also fixed across all segments in a given arc, but is allowed to vary between arcs.

replicates simply duplicates a sequence of segments for a given arc, which are then allowed to commence path traversal during unique plot frames based on max.offset. For example, if replicates=2 and max.offset=2, two instances of the same arc segment path sequence for a specific arc can begin on plot frames 0, 1, or 2. max.offset must be at least replicates - 1.

For direction="fixed", no change are made to data. direction="reverse" will switch the order of the points in the arc and direction="random" gives a probability of 0.5 that order is reversed. This is useful in the context of applying gc_paths over multiple great circle arcs as well as for simulations.

In the context of animating a sequence of plot frames, and holding other factors constant, the general rule of thumb is animations will appear to traverse the path of longer great circle arcs with greater speed than of shorter great circle arcs, taking about the same amount of time (number of frames) to complete the journey from endpoint to endpoint because each arc is composed of the same number of points. On the other hand, the more points an arc consists of, the slower it will be traversed. Another factor is the length of each segment along the path of the arc and how much each successive segment is allowed to overlap the previous one from one plot to the next. See gc_arcs regarding generating great circle arcs composed of varying numbers of points.

Overall, there is an interplay between the number of points composing an entire arc, the segment length (number of points composing the successive subsets of an arc), and degree of segment overlap (how the arc is broken into segments to trace the path along the arc). Longer segments made up of more points means the arc is traversed more quickly. More segment overlap will slow down the journey. More points composing the entire arc shrinks the distance covered by each segment.

Examples

# NOT RUN {
library(dplyr)
set.seed(192)
data(network)
distFun <- function(x) 1 - x / max(x) # simple inverse distance weighting
endpoints <- gc_endpoints(network, "lon", "lat")
endpoints <- mutate(endpoints, Dist_wts=distFun(Dist))

# take a weighted sample, e.g., favoring larger averaged populations and shorter distances
endpoints <- sample_n(endpoints, 500, replace=TRUE, weight=(Pop_wts0 + Pop_wts1)/2 + Dist_wts)

# expand data frame from endpoints to arcs, each composed of a sequence of points
arcs <- gc_arcs(endpoints, "lon0", "lat0", "lon1", "lat1")

paths <- gc_paths(arcs, group="group", size=5)
# }