Learn R Programming

mapmate (version 0.3.1)

do_projection: Project points onto globe

Description

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

Usage

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

Run this code
# NOT RUN {
library(dplyr)
library(purrr)
data(annualtemps)
temps <- mutate(annualtemps, frameID = Year - min(Year) + 1)
do_projection(temps, id="frameID")
do_projection(temps, id="frameID", keep=TRUE)
# }

Run the code above in your browser using DataLab