-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathget_heat_map.Rd
132 lines (107 loc) · 5.67 KB
/
get_heat_map.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_heat_map.R
\name{get_heat_map}
\alias{get_heat_map}
\alias{get_heat_map.list}
\alias{get_heat_map.actframe}
\alias{get_heat_map.strframe}
\title{Makes a heat map from your activity data}
\usage{
get_heat_map(act_data, ...)
\method{get_heat_map}{list}(
act_data,
key,
acts = 1,
id = NULL,
alpha = NULL,
add_elev = FALSE,
as_grad = FALSE,
distlab = TRUE,
distval = 0,
size = 0.5,
col = "red",
expand = 10,
maptype = "CartoDB.Positron",
zoom = 14,
units = "metric",
...
)
\method{get_heat_map}{actframe}(
act_data,
key,
alpha = NULL,
add_elev = FALSE,
as_grad = FALSE,
distlab = TRUE,
distval = 0,
size = 0.5,
col = "red",
expand = 10,
maptype = "CartoDB.Positron",
zoom = 14,
...
)
\method{get_heat_map}{strframe}(
act_data,
alpha = NULL,
filltype = "elevation",
distlab = TRUE,
distval = 0,
size = 0.5,
col = "red",
expand = 10,
maptype = "CartoDB.Positron",
zoom = 14,
...
)
}
\arguments{
\item{act_data}{an activities list object returned by \code{\link{get_activity_list}}, an \code{actframe} returned by \code{\link{compile_activities}}, or a \code{strfame} returned by \code{\link{get_activity_streams}}}
\item{...}{arguments passed to or from other methods}
\item{key}{chr string of Google API key for elevation data, passed to \code{\link[googleway]{google_elevation}} for polyline decoding, see details}
\item{acts}{numeric indicating which activities to plot based on index in the activities list, defaults to most recent}
\item{id}{optional character vector to specify the id(s) of the activity/activities to plot, \code{acts} is ignored if provided}
\item{alpha}{the opacity of the line desired. A single activity should be 1. Defaults to 0.5}
\item{add_elev}{logical indicating if elevation is shown by color shading on the activity lines}
\item{as_grad}{logical indicating if elevation is plotted as percent gradient, applies only if \code{add_elev = TRUE}}
\item{distlab}{logical if distance labels are plotted along the route}
\item{distval}{numeric indicating rounding factor for distance labels which has direct control on label density, see details}
\item{size}{numeric indicating width of activity lines}
\item{col}{chr string indicating either a single color of the activity lines if \code{add_grad = FALSE} or a color palette passed to \code{\link[ggplot2]{scale_fill_distiller}} if \code{add_grad = TRUE}}
\item{expand}{a numeric multiplier for expanding the number of lat/lon points on straight lines. This can create a smoother elevation gradient if \code{add_grad = TRUE}. Set \code{expand = 1} to suppress this behavior.}
\item{maptype}{chr string indicating the provider for the basemap, see details}
\item{zoom}{numeric indicating zoom factor for map tiles, higher numbers increase resolution}
\item{units}{chr string indicating plot units as either metric or imperial, this has no effect if input data are already compiled with \code{\link{compile_activities}}}
\item{filltype}{chr string specifying which stream variable to use for filling line segments, applies only to \code{strframe} objects, acceptable values are \code{"elevation"}, \code{"distance"}, \code{"slope"}, or \code{"speed"}}
}
\value{
A \code{\link[ggplot2]{ggplot}} object showing a map with activity locations.
}
\description{
Makes a heat map from your activity data
}
\details{
uses \code{\link{get_latlon}} to produce a dataframe of latitudes and longitudes to use in the map. Uses ggspatial to produce the map and ggplot2 to plot the route.
A Google API key is needed for the elevation data and must be included with function execution. The API key can be obtained following the instructions here: https://developers.google.com/maps/documentation/elevation/#api_key
The \code{distval} argument is passed to the \code{digits} argument of \code{round}. This controls the density of the distance labels, e.g., 1 will plot all distances in sequence of 0.1, 0 will plot all distances in sequence of one, -1 will plot all distances in sequence of 10, etc.
The base map type is selected with the \code{maptype} argument. The \code{zoom} value specifies the resolution of the map. Use higher values to download map tiles with greater resolution, although this increases the download time. Acceptable options for \code{maptype} include \code{"OpenStreetMap"}, \code{"OpenStreetMap.DE"}, \code{"OpenStreetMap.France"}, \code{"OpenStreetMap.HOT"}, \code{"OpenTopoMap"}, \code{"Esri.WorldStreetMap"}, \code{"Esri.DeLorme"}, \code{"Esri.WorldTopoMap"}, \code{"Esri.WorldImagery"}, \code{"Esri.WorldTerrain"}, \code{"Esri.WorldShadedRelief"}, \code{"Esri.OceanBasemap"}, \code{"Esri.NatGeoWorldMap"}, \code{"Esri.WorldGrayCanvas"}, \code{"CartoDB.Positron"}, \code{"CartoDB.PositronNoLabels"}, \code{"CartoDB.PositronOnlyLabels"}, \code{"CartoDB.DarkMatter"}, \code{"CartoDB.DarkMatterNoLabels"}, \code{"CartoDB.DarkMatterOnlyLabels"}, \code{"CartoDB.Voyager"}, \code{"CartoDB.VoyagerNoLabels"}, or \code{"CartoDB.VoyagerOnlyLabels"}.
}
\examples{
\dontrun{
# get my activities
stoken <- httr::config(token = strava_oauth(app_name, app_client_id, app_secret, cache = TRUE))
my_acts <- get_activity_list(stoken)
# default, requires Google key
mykey <- 'Get Google API key'
get_heat_map(my_acts, acts = 1, alpha = 1, key = mykey)
# plot elevation on locations, requires key
get_heat_map(my_acts, acts = 1, alpha = 1, key = mykey, add_elev = TRUE, col = 'Spectral', size = 2)
# compile first, change units
my_acts <- compile_activities(my_acts, acts = 156, units = 'imperial')
get_heat_map(my_acts, key = mykey, alpha = 1, add_elev = T, col = 'Spectral', size = 2)
}
}
\author{
Daniel Padfield, Marcus Beck
}
\concept{token}