| License: | GPL-3 |
| Title: | Extension to 'tmap' for Creating Network Visualizations |
| Type: | Package |
| Description: | Provides functions for visualizing networks with 'tmap'. It supports 'sfnetworks' objects natively but is not limited to them. Useful for adding network layers such as edges and nodes to 'tmap' maps. More features may be added in future versions. |
| Version: | 0.2-1 |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.0), |
| Imports: | tmap (≥ 4.3), sf, sfnetworks, lwgeom, data.table, igraph |
| Suggests: | knitr |
| Config/Needs/website: | bookdown, rmarkdown, r-tmap/tmap |
| URL: | https://github.com/r-tmap/tmap.networks, https://r-tmap.github.io/tmap.networks/ |
| BugReports: | https://github.com/r-tmap/tmap.networks/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-06-15 09:49:25 UTC; mtes |
| Author: | Martijn Tennekes [aut, cre],
Andrea Gilardi |
| Maintainer: | Martijn Tennekes <mtennekes@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-15 11:10:02 UTC |
Extension for tmap: networks
Description
Networks from sfnetworks are supported and several network specifc layer functions are added
Author(s)
Martijn Tennekes mtennekes@gmail.com
See Also
Useful links:
Report bugs at https://github.com/r-tmap/tmap.networks/issues
Map layer: edges of a (sf)network
Description
Map layer that draws the edges of a (sf)network.
Usage
tm_edges(
col = tmap::tm_const(),
col.scale = tmap::tm_scale(),
col.legend = tmap::tm_legend(),
col.free = NA,
lwd = tmap::tm_const(),
lwd.scale = tmap::tm_scale(),
lwd.legend = tmap::tm_legend(),
lwd.free = NA,
lty = tmap::tm_const(),
lty.scale = tmap::tm_scale(),
lty.legend = tmap::tm_legend(),
lty.free = NA,
col_alpha = tmap::tm_const(),
col_alpha.scale = tmap::tm_scale(),
col_alpha.legend = tmap::tm_legend(),
col_alpha.free = NA,
from = 0,
to = 1,
linejoin = "round",
lineend = "round",
plot.order = tmap::tm_plot_order("lwd", reverse = TRUE, na.order = "bottom"),
zindex = NA,
group = NA,
group.control = "check",
popup = tmap::tm_popup(),
popup.vars = NA,
popup.format = list(),
hover = NA,
id = "",
options = opt_tm_edges(),
...
)
opt_tm_edges(lines.only = "yes", offset_start = 0, offset_end = 0)
Arguments
col, col.scale, col.legend, col.free |
Visual variable that determines the col color. See details. |
lwd, lwd.scale, lwd.legend, lwd.free |
Visual variable that determines the line width. See details. |
lty, lty.scale, lty.legend, lty.free |
Visual variable that determines the line type. See details. |
col_alpha, col_alpha.scale, col_alpha.legend, col_alpha.free |
Visual variable that determines the border color alpha transparency. See details. |
from, to |
Numbers between 0 and 1 (where |
linejoin, lineend |
line join and line end. See |
plot.order |
Specification in which order the spatial features are drawn. See |
zindex |
Map layers are drawn on top of each other. The |
group |
Name of the group to which this layer belongs. This is only relevant in view mode, where layer groups can be switched (see |
group.control |
In view mode, the group control determines how layer groups can be switched on and off. Options: |
popup |
popup specification for |
popup.vars |
(Deprecated.) Use |
popup.format |
(Deprecated.) Use |
hover |
name of the data variable that specifies the hover labels (view mode only). Set to |
id |
name of the data variable that specifies the indices of the spatial
features. Only used for |
options |
options passed on to the corresponding |
... |
passed on to |
lines.only |
should only line geometries of the shape object (defined in |
offset_start, offset_end |
Offset in coordinates (usually meters) of the start and end points. |
Value
a tmap::tmap-element, supposed to be stacked after tmap::tm_shape() using the + operator. The opt_<layer_function> function returns a list that should be passed on to the options argument.
Examples
library(tmap)
library(sfnetworks)
sfn = as_sfnetwork(roxel)
tm_shape(sfn) +
tm_network()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4) +
tm_nodes()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4, from = 0.3, to = 0.4) +
tm_nodes()
Map layer: (sf)network
Description
Map layer that draws a network. For more (total) flexibility, please use tm_edges and tm_nodes.
Usage
tm_network()
Value
a tmap::tmap-element, supposed to be stacked after tmap::tm_shape() using the + operator. The opt_<layer_function> function returns a list that should be passed on to the options argument.
Examples
library(tmap)
library(sfnetworks)
sfn = as_sfnetwork(roxel)
tm_shape(sfn) +
tm_network()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4) +
tm_nodes()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4, from = 0.3, to = 0.4) +
tm_nodes()
Map layer: nodes of a (sf)network
Description
Map layer that draws the nodes of a (sf)network.
Usage
tm_nodes(
size = tm_const(),
size.scale = tm_scale(),
size.legend = tm_legend(),
size.free = NA,
fill = tm_const(),
fill.scale = tm_scale(),
fill.legend = tm_legend(),
fill.free = NA,
col = tm_const(),
col.scale = tm_scale(),
col.legend = tm_legend(),
col.free = NA,
shape = tm_const(),
shape.scale = tm_scale(),
shape.legend = tm_legend(),
shape.free = NA,
lwd = tm_const(),
lwd.scale = tm_scale(),
lwd.legend = tm_legend(),
lwd.free = NA,
lty = tm_const(),
lty.scale = tm_scale(),
lty.legend = tm_legend(),
lty.free = NA,
fill_alpha = tm_const(),
fill_alpha.scale = tm_scale(),
fill_alpha.legend = tm_legend(),
fill_alpha.free = NA,
col_alpha = tm_const(),
col_alpha.scale = tm_scale(),
col_alpha.legend = tm_legend(),
col_alpha.free = NA,
plot.order = tm_plot_order("size"),
zindex = NA,
group = NA,
group.control = "check",
popup = tm_popup(),
popup.vars = NA,
popup.format = list(),
hover = NA,
id = "",
options = opt_tm_nodes(),
...
)
opt_tm_nodes(
points_only = "yes",
point_per = "feature",
on_surface = FALSE,
clustering = FALSE,
icon.scale = 3,
just = NA,
grob.dim = c(width = 48, height = 48, render.width = 256, render.height = 256)
)
Arguments
size, size.scale, size.legend, size.free |
Visual variable that determines the size. See details. |
fill, fill.scale, fill.legend, fill.free |
Visual variable that determines the fill color. See details. |
col, col.scale, col.legend, col.free |
Visual variable that determines the col color. See details. |
shape, shape.scale, shape.legend, shape.free |
Visual variable that determines the shape. See details. |
lwd, lwd.scale, lwd.legend, lwd.free |
Visual variable that determines the line width. See details. |
lty, lty.scale, lty.legend, lty.free |
Visual variable that determines the line type. See details. |
fill_alpha, fill_alpha.scale, fill_alpha.legend, fill_alpha.free |
Visual variable that determines the fill color alpha transparency See details. |
col_alpha, col_alpha.scale, col_alpha.legend, col_alpha.free |
Visual variable that determines the border color alpha transparency. See details. |
plot.order |
Specification in which order the spatial features are drawn. See |
zindex |
Map layers are drawn on top of each other. The |
group |
Name of the group to which this layer belongs. This is only relevant in view mode, where layer groups can be switched (see |
group.control |
In view mode, the group control determines how layer groups can be switched on and off. Options: |
popup |
popup specification for |
popup.vars |
(Deprecated.) Use |
popup.format |
(Deprecated.) Use |
hover |
name of the data variable that specifies the hover labels (view mode only). Set to |
id |
name of the data variable that specifies the indices of the spatial
features. Only used for |
options |
options passed on to the corresponding |
... |
passed on to |
points_only |
should only point geometries of the shape object (defined in |
point_per |
specification of how spatial points are mapped when the geometry is a multi line or a multi polygon. One of |
on_surface |
In case of polygons, centroids are computed. Should the points be on the surface? If |
clustering |
in interactive modes (e.g. |
icon.scale |
scaling number that determines how large the icons (or grobs) are in plot mode in comparison to proportional symbols (such as bubbles). For view mode, use the argument |
just |
not used (yet) |
grob.dim |
vector of four values that determine how grob objects (see details) are shown in view mode. The first and second value are the width and height of the displayed icon. The third and fourth value are the width and height of the rendered png image that is used for the icon. Generally, the third and fourth value should be large enough to render a ggplot2 graphic successfully. Only needed for the view mode. |
Value
a tmap::tmap-element, supposed to be stacked after tmap::tm_shape() using the + operator. The opt_<layer_function> function returns a list that should be passed on to the options argument.
Examples
library(tmap)
library(sfnetworks)
sfn = as_sfnetwork(roxel)
tm_shape(sfn) +
tm_network()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4) +
tm_nodes()
tm_shape(sfn) +
tm_edges(col = "type", lwd = 4, from = 0.3, to = 0.4) +
tm_nodes()
Implementation of tmapGetShapeMeta1 for linnet
Description
Implementation of tmapGetShapeMeta1 for linnet
Usage
## S3 method for class 'linnet'
tmapGetShapeMeta1(shp, layer, o)
Value
list used by tmap internally
Implementation of tmapGetShapeMeta1 for sfnetwork
Description
Implementation of tmapGetShapeMeta1 for sfnetwork
Usage
## S3 method for class 'sfnetwork'
tmapGetShapeMeta1(shp, layer, o)
Value
list used by tmap internally
Implementation of tmapGetShapeMeta2 for linnet
Description
Implementation of tmapGetShapeMeta2 for linnet
Usage
## S3 method for class 'linnet'
tmapGetShapeMeta2(shp, smeta, o)
Value
list used by tmap internally
Implementation of tmapGetShapeMeta2 for sfnetwork
Description
Implementation of tmapGetShapeMeta2 for sfnetwork
Usage
## S3 method for class 'sfnetwork'
tmapGetShapeMeta2(shp, smeta, o)
Value
list used by tmap internally
Internal methods
Description
Internal methods
Usage
## S3 method for class 'tm_data_network'
tmapGridDataPlot(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
## S3 method for class 'tm_data_edges'
tmapGridDataPlot(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
## S3 method for class 'tm_data_nodes'
tmapGridDataPlot(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
## S3 method for class 'tm_data_network'
tmapLeafletDataPlot(
a,
shpTM,
dt,
pdt,
popup.format,
hdt,
idt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
## S3 method for class 'tm_data_edges'
tmapLeafletDataPlot(
a,
shpTM,
dt,
pdt,
popup.format,
hdt,
idt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
## S3 method for class 'tm_data_nodes'
tmapLeafletDataPlot(
a,
shpTM,
dt,
pdt,
popup.format,
hdt,
idt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMapboxDataPlot.tm_data_network(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMapboxDataPlot.tm_data_edges(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMapboxDataPlot.tm_data_nodes(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMaplibreDataPlot.tm_data_network(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMaplibreDataPlot.tm_data_edges(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
tmapMaplibreDataPlot.tm_data_nodes(
a,
shpTM,
dt,
gp,
bbx,
facet_row,
facet_col,
facet_page,
id,
pane,
group,
glid,
o,
...
)
Implementation of tmapShape for sfnetwork
Description
Implementation of tmapShape for sfnetwork
Usage
## S3 method for class 'sfnetwork'
tmapShape(
shp,
is.main,
crs,
bbox,
unit,
filter,
layer,
shp_name,
smeta,
o,
tmf
)
Value
list used by tmap internally
Implementation of tmapSubsetShp for linnet
Description
Implementation of tmapSubsetShp for linnet
Usage
## S3 method for class 'linnet'
tmapSubsetShp(shp, vars)
Value
list used by tmap internally
Implementation of tmapSubsetShp for sfnetwork
Description
Implementation of tmapSubsetShp for sfnetwork
Usage
## S3 method for class 'sfnetwork'
tmapSubsetShp(shp, vars)
Value
list used by tmap internally