flowmap {cartograflow}R Documentation

Mapping of an origin-destination flow matrix

Description

Mapping of an origin-destination flow matrix

Usage

flowmap(
  tab,
  fij,
  origin.f,
  destination.f,
  bkg = NULL,
  crs,
  nodes = NULL,
  code,
  nodes.X,
  nodes.Y,
  filter,
  plota,
  threshold,
  taille,
  a.head,
  a.length,
  a.angle,
  a.col,
  add = NULL,
  ...
)

Arguments

tab

the input flow dataset in .csv format. See Details

fij

the flow value between origin and destination places

origin.f

the place of origin code

destination.f

the place of destination code

bkg

a spatial feature layer, as a map background, in .shp or .json or other format

crs

the coordinate reference system (CRS)

nodes

the input points file in .csv format

code

the spatial features code

nodes.X

the X coordinate of the point or places

nodes.Y

the Y coordinate of the point or places

filter

is to filter or not the flow values. See details

plota

is to add spatial features as map background to the flows's plot

threshold

the value of the threshold criterion to filter flows. Default is 1.

taille

the value of the width of the flow feature

a.head

for arrow's head is the arrow head parameter code. It allows to choose the kind of arrow. See Details

a.length

for arrow's length is the length of the edges of the arrow head (in inches)

a.angle

for arrow's angle is the angle from the shaft of the arrow to the edge of the arrow head

a.col

for arrow's color

add

is to allow to overlay flow features on external spatial features background

...

Adds the set of variables of the arrow function

Details

The input .csv flow dataset must be first converted to a dataframe for optimal performance (troubles remains with tibble format)

- filter is "FALSE" means that all the flow value will be plot as segments [(n*(n-1)], i.e. all the OD matrice's cells out of the main diagonal will be plot.
- filter is "TRUE" means only non-zero values will be plot, i.e. existing links with or without threshold.
The default threshold is set to 1.

Flow features are plot as segments betwwen (x0,y0) and (x1,y1)
- a.head is for applying an arrow or not to a segment:
– code="0" : the link has no head - no arrow
– code="1" : an arrow is draw at (x0[i], y0[i])
– code="2" : an arrow is draw at (x1[j], y1[j])
– code="3" : an arrow is draw at both nodes.

Value

a matrix or a list with the correct flow dataframe ID code

The resulting flowmap

Examples

library(cartograflow)
library(sf)
data(flowdata)
# example with the background
map <- st_read(system.file("shape/MGP_TER.shp", package = "cartograflow"))
par(bg = "NA")
plot(st_geometry(map), col = "blue")
flowmap(
  tab = flows, fij = "Fij", origin.f = "i", destination.f = "j",
  bkg = map,add=TRUE, code = "EPT_NUM", nodes.X = "X", nodes.Y = "Y",
  filter = FALSE
)

# example with nodes files
map <- st_read("MGP_territoires.json")
pt <- read.csv2("points.csv")# points files origin destination
flows<-red.cs2("flows.csv") # flows files 
par(bg = "NA")
plot(st_geometry(map), col = "blue")
flowmap(tab = flows, fij = "d", origin.f = "a", destination.f = "b",
        crs=4326,nodes = pt, code = "EPT_NUM", nodes.X = "X", nodes.Y = "Y",
        filter = TRUE,add=TRUE,threshold = 10, taille = 8,arr.length = 0.1)


[Package cartograflow version 1.0.3 Index]