Title: | Flow Map Rendering |
---|---|
Description: | Create interactive flow maps using 'FlowmapBlue' 'TypeScript' library <https://github.com/FlowmapBlue/FlowmapBlue>, which is a free tool for representing aggregated numbers of movements between geographic locations as flow maps. It is used to visualize urban mobility, commuting behavior, bus, subway and air travels, bicycle sharing, human and bird migration, refugee flows, freight transportation, trade, supply chains, scientific collaboration, epidemiological and historical data and many other topics. The package allows to either create standalone flow maps in form of 'htmlwidgets' and save them in 'HTML' files, or integrate flow maps into 'Shiny' applications. |
Authors: | Ilya Boyandin [aut, cph] |
Maintainer: | Egor Kotov <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.2 |
Built: | 2025-02-28 16:10:22 UTC |
Source: | https://github.com/flowmapblue/flowmapblue.r |
A dataset containing flow data between various locations in Switzerland. This data represents the flow counts between origin and destination locations, identified by their unique codes.
ch_flows
ch_flows
ch_flows
A data frame with 676 rows and 3 columns:
A character
vector representing the origin location identifier (must match the id
in the ch_locations
dataset).
A character
vector representing the destination location identifier (must match the id
in the ch_locations
dataset).
An integer
vector representing the flow count between the origin and destination locations.
A dataset containing geographic information about 26 locations in Switzerland. This data includes unique identifiers, names, and geographic coordinates (latitude and longitude) for each location.
ch_locations
ch_locations
ch_locations
A data frame with 26 rows and 4 columns:
A character
vector representing the unique identifier for each Swiss location (e.g., "JU", "LU").
A character
vector representing the name of each location (e.g., "Jura", "Luzern").
A numeric
vector representing the latitude of each location in WGS84 (EPSG: 4326) coordinate reference system.
A numeric
vector representing the longitude of each location in WGS84 (EPSG: 4326) coordinate reference system.
Creates an interactive flow map visualizing flows between various locations and outputs it as an HTML widget. This function utilizes the FlowmapBlue
library to create maps with customizable options such as clustering, animation, and dark mode. The widget can be rendered in R Markdown, Shiny, or viewed in a browser. It can also be saved to html
file with htmlwidgets:saveWidget()
. See examples for more details.
flowmapblue( locations, flows, mapboxAccessToken = NULL, clustering = TRUE, animation = FALSE, darkMode = FALSE )
flowmapblue( locations, flows, mapboxAccessToken = NULL, clustering = TRUE, animation = FALSE, darkMode = FALSE )
locations |
A
|
flows |
A
|
mapboxAccessToken |
A |
clustering |
A |
animation |
A |
darkMode |
A |
An HTML widget of class flowmapblue
and htmlwidget
that can be rendered in R Markdown, Shiny, or viewed in a browser. It can also be saved to html
file with htmlwidgets:saveWidget()
. See examples for more details.
## Not run: # example 1, normal flows # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland locations <- data(ch_locations) flows <- data(ch_flows) flowmap <- flowmapblue( locations, flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap # or save it as an HTML file htmlwidgets::saveWidget(flowmap, file = "flowmap.html") # example 2, flows with date in time column # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland data(ch_locations) data(ch_flows) # generate fake datetime flows$time <- seq(from =as.POSIXct("2020-01-01"), to = as.POSIXct("2020-01-05"), length.out = nrow(flows)) flowmap <- flowmapblue( ch_locations, ch_flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap # example 3, flows with date in time column # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland data(ch_locations) data(ch_flows) # generate fake dates flows$time <- seq(from = as.Date("2020-01-01"), to = as.Date("2020-06-01"), length.out = nrow(flows)) flowmap <- flowmapblue( ch_locations, ch_flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap ## End(Not run)
## Not run: # example 1, normal flows # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland locations <- data(ch_locations) flows <- data(ch_flows) flowmap <- flowmapblue( locations, flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap # or save it as an HTML file htmlwidgets::saveWidget(flowmap, file = "flowmap.html") # example 2, flows with date in time column # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland data(ch_locations) data(ch_flows) # generate fake datetime flows$time <- seq(from =as.POSIXct("2020-01-01"), to = as.POSIXct("2020-01-05"), length.out = nrow(flows)) flowmap <- flowmapblue( ch_locations, ch_flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap # example 3, flows with date in time column # set your Mapbox access token Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN") # load locations and flows for Switzerland data(ch_locations) data(ch_flows) # generate fake dates flows$time <- seq(from = as.Date("2020-01-01"), to = as.Date("2020-06-01"), length.out = nrow(flows)) flowmap <- flowmapblue( ch_locations, ch_flows, mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'), clustering = TRUE, darkMode = TRUE, animation = FALSE ) # view the map flowmap ## End(Not run)
Output and render functions for using flowmapblue within Shiny applications and interactive Rmd documents.
flowmapblueOutput(outputId, width = "100%", height = "400px") renderFlowmapblue(expr, env = parent.frame(), quoted = FALSE)
flowmapblueOutput(outputId, width = "100%", height = "400px") renderFlowmapblue(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from. |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a |
env |
The environment in which to evaluate |
quoted |
Is |
flowmapblueOutput
Returns a shiny.tag.list
object that can be included in a Shiny UI to display the flowmapblue
widget.
renderFlowmapblue
Returns a shiny.render.function
that is used to generate the flowmapblue
widget on the server side in a Shiny application.
shinyWidgetOutput
, shinyRenderWidget