Description Usage Arguments Value Author(s) See Also Examples
View source: R/add_colourscale.R
This function adjusts the colour scales of the animation frames created with frames_spatial
and custom map imagery.
1 2 3 4 5 6 7 8 9 10 |
frames |
list of |
type |
character, either |
colours |
character, a vector of colours. If |
labels |
character, a vector of labels with the same length as |
na.colour |
character, colour to use for missing values. |
na.show |
logical, whether to display NA values in discrete scaling. Ignored, if |
legend_title |
character, a legend title. |
verbose |
logical, if |
List of frames.
Jakob Schwalb-Willmann
frames_spatial
frames_graph
animate_frames
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 | library(moveVis)
library(move)
data("move_data", "basemap_data")
# align movement
m <- align_move(move_data, res = 4, unit = "mins")
# create spatial frames with frames_spatial:
r_list <- basemap_data[[1]]
r_times <- basemap_data[[2]]
frames <- frames_spatial(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE)
frames[[100]] # take a look at one of the frames
# default blue is boring, let's change the colour scale of all frames
frames <- add_colourscale(frames, type = "gradient", colours = c("orange", "white", "darkgreen"),
legend_title = "NDVI")
frames[[100]]
# let's make up some classification data with 10 classes
r_list <- lapply(r_list, function(x){
y <- raster::setValues(x, round(raster::getValues(x)*10))
return(y)
})
# turn fade_raster to FALSE, since it makes no sense to temporally interpolate discrete classes
frames <- frames_spatial(m, r_list = r_list, r_times = r_times, r_type = "discrete",
fade_raster = FALSE)
frames[[100]]
# now, let's assign a colour per class value to frames
colFUN <- colorRampPalette(c("orange", "lightgreen", "darkgreen"))
cols <- colFUN(10)
frames <- add_colourscale(frames, type = "discrete", colours = cols, legend_title = "Classes")
frames[[100]]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.