Learn R Programming

googleway (version 2.7.1)

update_heatmap: update heatmap

Description

updates a heatmap layer

Usage

update_heatmap(map, data, lat = NULL, lon = NULL, weight = NULL,
  option_gradient = NULL, option_dissipating = FALSE,
  option_radius = 0.01, option_opacity = 0.6, layer_id = NULL,
  update_map_view = TRUE, digits = 4, legend = F, legend_options = NULL)

Arguments

map

a googleway map object created from google_map()

data

data frame containing the data to use in the layer. If Null, the data passed into google_map() will be used.

lat

string specifying the column of data containing the 'latitude' coordinates. If left NULL, a best-guess will be made

lon

string specifying the column of data containing the 'longitude' coordinates. If left NULL, a best-guess will be made

weight

string specifying the column of data containing the 'weight' associated with each point. If NULL, each point will get a weight of 1.

option_gradient

vector of colours to use as the gradient colours. see Details

option_dissipating

logical Specifies whether heatmaps dissipate on zoom. When dissipating is FALSE the radius of influence increases with zoom level to ensure that the color intensity is preserved at any given geographic location. When set to TRUE you will likely need a greater option_radius value. Defaults to FALSE.

option_radius

numeric. The radius of influence for each data point, in pixels. Defaults to 0.01

option_opacity

The opacity of the heatmap, expressed as a number between 0 and 1. Defaults to 0.6.

layer_id

single value specifying an id for the layer. Use this value to distinguish between shape layers for when using any update_ function, and for separating legends.

update_map_view

logical specifying if the map should re-centre according to the shapes

digits

integer. Use this parameter to specify how many digits (decimal places) should be used for the latitude / longitude coordinates.

legend

either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend.

legend_options

A list of options for controlling the legend.

Details

The option_gradient is only used to craete the legend, and not to change the colours of the heat layer. If you are not displaying a legend this argument is not needed. If you are displaying a legend, you should provide the same gardient as in the add_heatmap call.

Examples

Run this code
# NOT RUN {
map_key <- 'your_api_key'

set.seed(20170417)
df <- tram_route
df$weight <- sample(1:10, size = nrow(df), replace = T)

google_map(key = map_key, data = df) %>%
 add_heatmap(lat = "shape_pt_lat", lon = "shape_pt_lon", weight = "weight",
              option_radius = 0.001)

## update by adding the same data again to double the number of points at each location
df_update <- df
google_map(key = map_key, data = df) %>%
 add_heatmap(lat = "shape_pt_lat", lon = "shape_pt_lon", weight = "weight",
              option_radius = 0.001) %>%
 update_heatmap(df_update, lat = "shape_pt_lat", lon = "shape_pt_lon")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab