Project points in data onto the globe and filter data to points within the current field of view.

do_projection(data, id, lon = 0, lat = 0, n.period = 360,
  n.frames = n.period, keep = FALSE)

Arguments

data

a data frame.

id

character, column name referring to column of data representing frame sequence integer IDs.

lon

starting longitude for rotation sequence or vector of arbitrary longitude sequence.

lat

fixed latitude or vector of arbitrary latitude sequence.

n.period

intended length of the period.

n.frames

intended number of frames in animation.

keep,

if TRUE, return the entire input data drame (no subsetting) along with the boolean inview column. Otherwise only return the row-filtered data frame with its original columns. Defaults to FALSE.

Value

returns a data frame containing visible points on the globe or all points along with a boolean inview column.

Details

do_projection projects the coordinates in data onto the globe and filters data to the subset of rows containing data which are visible given the current field of view. The field of view is defined by the centroid focus latitude and longitude pair in the sequence of latitudes and longitudes whose index corresponds to the frame ID in data. data may containing rows with multiple unique frame ID values, which the function will group the data by. These values are used to determine position in the user-defined lon/lat sequence and the corresponding in-view subset of data for each subset of data grouped by the `id` variable.

Examples

library(dplyr) library(purrr) data(annualtemps) temps <- mutate(annualtemps, frameID = Year - min(Year) + 1) do_projection(temps, id="frameID")
#> Joining, by = c("lon", "lat", "frameID")
#> # A tibble: 28,641 x 5 #> lon lat Year z frameID #> <dbl> <dbl> <int> <dbl> <dbl> #> 1 -90 0.333 2010 0.33 1 #> 2 -90 13.7 2010 0.69 1 #> 3 -90 20.3 2010 0.54 1 #> 4 -90 27.0 2010 1.1 1 #> 5 -90 33.7 2010 1.35 1 #> 6 -90 40.3 2010 1.49 1 #> 7 -90 47.0 2010 1.24 1 #> 8 -90 53.7 2010 0.79 1 #> 9 -90 60.3 2010 1.4 1 #> 10 -90 67.0 2010 1.96 1 #> # ... with 28,631 more rows
do_projection(temps, id="frameID", keep=TRUE)
#> Joining, by = c("lon", "lat", "frameID")
#> # A tibble: 55,080 x 6 #> lon lat Year z frameID inview #> <dbl> <dbl> <int> <dbl> <dbl> <lgl> #> 1 -177. 53.7 2010 1.09 1 FALSE #> 2 -177. 67.0 2010 3.21 1 FALSE #> 3 -177. 73.7 2010 2.76 1 FALSE #> 4 -170 53.7 2010 0.91 1 FALSE #> 5 -170 60.3 2010 2.47 1 FALSE #> 6 -170 67.0 2010 2.73 1 FALSE #> 7 -163. 20.3 2010 0.19 1 FALSE #> 8 -163. 53.7 2010 0.79 1 FALSE #> 9 -163. 60.3 2010 1.43 1 FALSE #> 10 -163. 67.0 2010 1.28 1 FALSE #> # ... with 55,070 more rows