Title: | Flow Map Rendering |
Version: | 0.0.2 |
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. |
License: | MIT + file LICENSE |
URL: | https://github.com/FlowmapBlue/flowmapblue.R, https://flowmapblue.github.io/flowmapblue.R/ |
BugReports: | https://github.com/FlowmapBlue/flowmapblue.R/issues |
Depends: | R (≥ 2.10) |
Imports: | htmlwidgets |
Suggests: | quarto |
VignetteBuilder: | quarto |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2024-09-03 17:01:04 UTC; ek |
Author: | Ilya Boyandin |
Maintainer: | Egor Kotov <kotov.egor@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-09-05 17:20:08 UTC |
Swiss Flows Dataset
Description
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.
Usage
ch_flows
Format
ch_flows
A data frame with 676 rows and 3 columns:
- origin
A
character
vector representing the origin location identifier (must match theid
in thech_locations
dataset).- dest
A
character
vector representing the destination location identifier (must match theid
in thech_locations
dataset).- count
An
integer
vector representing the flow count between the origin and destination locations.
Swiss Locations Dataset
Description
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.
Usage
ch_locations
Format
ch_locations
A data frame with 26 rows and 4 columns:
- id
A
character
vector representing the unique identifier for each Swiss location (e.g., "JU", "LU").- name
A
character
vector representing the name of each location (e.g., "Jura", "Luzern").- lat
A
numeric
vector representing the latitude of each location in WGS84 (EPSG: 4326) coordinate reference system.- lon
A
numeric
vector representing the longitude of each location in WGS84 (EPSG: 4326) coordinate reference system.
Create an interactive flow map
Description
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.
Usage
flowmapblue(
locations,
flows,
mapboxAccessToken = NULL,
clustering = TRUE,
animation = FALSE,
darkMode = FALSE
)
Arguments
locations |
A
|
flows |
A
|
mapboxAccessToken |
A |
clustering |
A |
animation |
A |
darkMode |
A |
Value
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.
Examples
## 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
locations <- data(ch_locations)
flows <- 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(
locations,
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
locations <- data(ch_locations)
flows <- 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(
locations,
flows,
mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'),
clustering = TRUE,
darkMode = TRUE,
animation = FALSE
)
# view the map
flowmap
## End(Not run)
Shiny bindings for flowmapblue
Description
Output and render functions for using flowmapblue within Shiny applications and interactive Rmd documents.
Usage
flowmapblueOutput(outputId, width = "100%", height = "400px")
renderFlowmapblue(expr, env = parent.frame(), quoted = FALSE)
Arguments
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 |
Value
flowmapblueOutput
Returns a
shiny.tag.list
object that can be included in a Shiny UI to display theflowmapblue
widget.renderFlowmapblue
Returns a
shiny.render.function
that is used to generate theflowmapblue
widget on the server side in a Shiny application.