Skip to content

Instantly share code, notes, and snippets.

View 16EAGLE's full-sized avatar
🛰️

J. Schwalb-Willmann 16EAGLE

🛰️
View GitHub Profile
@16EAGLE
16EAGLE / moveVis_add_custom_map_service.R
Created April 3, 2020 09:42
Short example on how to add additional tile API URLs for downloading base maps
library(moveVis)
# example data
data("move_data")
m <- align_move(m = move_data, res = 4, unit = "mins")
# add new service to moveVis, e.g. an ESRI layer
services <- getOption("moveVis.map_api")
services$esri <- list(hillshade = "https://services.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade_Dark/MapServer/tile/")
options(moveVis.map_api = services)
@16EAGLE
16EAGLE / moveVis_colours_by_variable.R
Last active December 23, 2023 00:06
Short moveVis example on how to colour paths based on a continuous variable
# use moveVis >= 0.10.2 for this example
library(moveVis)
library(move)
library(plyr)
# get example data. align movement to unique times and regular resolution
data("move_data")
m.aligned <- align_move(move_data, res = 4, unit = "mins")
# let's create some fake continous variable by splitting the moveStack into single tracks
@16EAGLE
16EAGLE / moveVis_hold_last_frame.R
Created April 25, 2019 14:47
Short moveVis example on how to hold the last frame of an animation for a defined time and make it look good by using path_fade
# use moveVis >= 0.10.2 for this example (does not work with CRAN version 0.10.1)
# remotes::install_github("16eagle/moveVis")
library(moveVis)
library(move)
data("move_data")
# align movement to unique times and regular resolution
m <- align_move(m = move_data, digit = 0, res = 4, unit = "mins")
@16EAGLE
16EAGLE / moveVis_show_traces.R
Last active December 23, 2023 00:07
Short moveVis example on how to display the full traces of each path using trace_show and trace_colour with frames_spatial()
# use moveVis >= 0.10.2 for this example (does not work with CRAN version 0.10.1)
# remotes::install_github("16eagle/moveVis")
library(magrittr)
library(move)
library(moveVis)
data("move_data")
m <- align_move(move_data, res = 4, unit = "mins")
@16EAGLE
16EAGLE / moveVis_colours_by_change_points.R
Last active December 23, 2023 00:05
Short moveVis example on how to assign multiple path colours per individual to indicate e.g. behavioral segments
# use moveVis >= 0.10.1 for this example
library(moveVis)
library(move)
data("move_data")
# align movement to unique times and regular resolution
m.aligned <- align_move(move_data, res = 4, unit = "mins")
m.split <- split(m.aligned)
@16EAGLE
16EAGLE / moveVis_overlay_base_map_with_transparent_rasters.R
Created March 7, 2019 13:49
Short moveVis example on how to overlay frames with additional transparent rasters changing over time
library(moveVis)
library(move)
library(ggplot2)
data("move_data", "basemap_data")
m <- align_move(move_data, res = 4, unit = "mins")
## create frames using mapbox base map
frames <- frames_spatial(m, map_type = "satellite", map_service = "mapbox", map_token = "YOUR_VERY_LONG_TOKEN",
path_legend = T)
@16EAGLE
16EAGLE / moveVis_get_coordinates_per_frame.R
Created March 7, 2019 13:45
Short moveVis example on how to create a data.frame containing each track coordinate per frame
# this example uses internal functions since there are no user functions yet to do this
library(moveVis)
data("move_data")
m <- align_move(move_data, res = 4, unit = "mins")
# m must be aligned, check (returns an error, if m is not aligned, does nothing, if m is aligned)
moveVis:::.time_conform(m)
# if you are certain, m is the same variable you used with frames_spatial, you can remove line 9
@16EAGLE
16EAGLE / moveVis_adapt_legend.R
Last active March 7, 2019 09:27
Short moveVis example on how to adapt the path legend of frames created with frames_spatial()
library(moveVis)
library(move)
library(ggplot2)
data("move_data")
# align movement to unique times and regular resolution
m <- align_move(move_data, res = 4, unit = "mins")
# some path colours by individual
m.list <- split(m) # split m into list by individual