Filtering origin-destination Matrices for Thematic Flowmapping
This package is designed to filter origin-destination matrices for flow mapping purposes. It is based on different functions that are mainly used to prepare the flow dataset (pre-processing, filtering ...). It also allows to plot flows in the form of segments and arrows, to map and customize them (compatible sf
& cartography
).
Installing cartograflow CRAN version:
install.packages("cartograflow")
To upgrade to the development version :
See Follow up updates
install.packages("devtools")
library("devtools")
remotes::install_github(url = "https://github.com/fbahoken/cartogRaflow")
Work in progress :
Coding of flowplaces()
and flowlowup()
for "M" format.
Towards flow filtering for local point of view (major, dominant...).
[20/07/2020] cartograflow
CRAN Update to 1.0.3
Updated functions : flowtype()
New function : flowplace()
, flowlowup()
[16/07/2020] flowlowup()
flowlowup()
(currently available for "L" format of matrix),
is to extracts the upper or the lower triangular part of a matrix.
[05/06/2020] flowplaces()
flowplace()
(currently available for "L" format of matrix),
is to compute flows margins indicators (on i,j) for places-based flow analysis.
[02/06/2020] cartograflow
CRAN Update to 1.0.2
Suppression of the dependencies in the namespace files gdata and rgdal.
Updated flowtype()
[1.0.0] cartograflow
initial CRAN version
Vignette cartograflow general presentation - CRAN version 1.0.3
subVignette : cartograflow concentration - v. 1.0.2
subVignette : cartograflow distance - v. 1.0.2
subVignette : cartograflow ordinal distance - v. 1.0.2
-flowcarre()
is to transform an un-square to a square matrice from a list of spatial objets ID (code).
-flowjointure()
is to performs a spatial join between a flow dataset and a map background.
-flowtabmat()
is to transform a matrice format to a long format and vice versa.
-flowstructmat()
fixes an unpreviously ID shift in the flow dataset "M" format. If necessary this function is to be used with flowjointure()
and flowtabmat
.
Check if the matrix is close and square. See flowcarre()
if not.
-flowtype()
is to compute the main types of bilateral flows from an asymmetric flow dataset (matrice or long format).
x = "flux" for remaining initial flow (Fij)
or x = "transpose" for reverse flow value (Fji)
or x = "bivolum" for bilateral volum as gross flow (FSij)=(Fij+Fji)
or x = "bibal" for bilateral balance as net flow (FBij)=(Fij-Fji)
or x = "biasym" for asymetry of bilateral flow (FSij)=(FBij/FSij)
or x = "bimin" for (minFij)=(Fij, Fji)
or x = "bimax" for (maxFij(Fij, Fji))
or x = "birange" for bilateral rangeFij=(maxFij - minFij)
or x = "bidisym" for bilateral disymetry as (FDij)=(rangeFij/FSij).
For x = "bivolum": (or for symetric matrix)
lowup = "up" for reducing the resulting matrix to the triangular sub-portion above the main diagonal
lower = "low" for the sub-portion below the main diagonal
For x = "bibal": (or for antisymetric matrix)
net = "positive" for extracting the positive flow values
net = "negative" for extracting the negative flow values.
flowplaces()
is to compute flow indicators from the margins of the matrix, e.g. on the flow's places of origin and/or destination.
x = "ini" for the number of incoming links (in-degree)
or x = "outi" for the number of outcoming links (out-degree)
or x = "degi" for the total number of links ini=(ini + outi)
or x = "intra" for the total intra zonal interaction (if main diagonal is not empty)
or x = "Oi" for the total flows emitted by (i) place
or x = "Dj" for the total flows received by (j) place
or x = "voli" for the total flow volume by place
or x = "bali" for the net balance by place
or x = "asyi" for the asymetry of flow by place
or x = "allflowplaces" for computing all the above indicators.
flowgini()
performs a concentration analysis of a flow dataset - To be use before flowanalysis()
Computes Gini coefficient and plot Lorenz curve
flowanalysis()
for computing a flow filter based on a double criterion for selecting flows before mapping.
See : subVignette : cartograflow concentration
See : subVignette : cartograflow distance
You have two ways to consider the distance travelled by flows :
-- if you have a matrice distance, go directly to flowreduct()
at §2.2.3 ;
-- if not, you can continue here, and have to choose the type of metric (continous or ordinal)
- if you choose the continous metric, you must first join your flows' dataset to a spatial shape, using
flowjointure()
, then useflowdist()
as described below
2.2.1. Compute continuous distances matrices
-flowjointure()
performs an attribute spatial join - by origin (i) and by destination (j) - between a flow dataset and a spatial shape in order to transfert the origin-destination coordinates (Xi, Yi, Xj, Yj) of the base map to the flow matrice.
flowdist()
Computes a continous distance matrice choosing metric ("rectilinear", "euclidian", "manhattan") before using flowreduct()
to filter the flow dataset.
2.2.2. Compute ordinal distances matrices
See : subVignette : cartograflow ordinal distance
flowcontig()
is to compute an ordinal distance matrice based on a k-contiguity matrice.
3.1. Reducing by extracting the lower / upper part of a matrix
flowlowup()
is to extracts the upper or the lower triangular part of a matrix - preferably for symmetrical matrixes.
x = "up" for the part above the main diagonal
x = "low" for the part below the main diagonal.
3.2. Reducting a flow matrice by an external matrice
flowreduct()
is to reduce the flow dataset regarding another matrix, e.g. distances travelled.
metric
is the metric of the distance matrix :
- metric=
continuous
(e.g. for kilometers) - metric=
ordinal
(e.g. fork
contiguity)
If metric = continuous
(e.g for filtering flows by kilometric distances travelled), use:
d.criteria
is for selecting the minimum or the maximum distance criteria
- d.criteria=
dmin
for keeping only flows up to a dmin criterion in km - d.criteria=
dmax
for selecting values less than a dmax criterion in km
d
is the value of the selecteddmin
ordmax
criteria.
See : subVignette : cartograflow distance
flowmap()
is to plot flows as segments or arrows. Arguments are:
filter
is to filter or not flow's information or features
threshold
is used to set the filtering level of the flows when filter="True"
taille
is the value of the width of the flow feature
a.head
is the arrow head parameter 0: no arrow, 1:i->j, 2:i<-j, 3:i<->j.
a.length
is the length of the edges of the arrow head (in inches)
a.angle
is the angle from the shaft of the arrow to the edge of the arrow head
a.col
is the arrow's color
plota
is to add spatial features as map background to the flows's plot
add
is to allow to overlay flow features on external spatial features background
References : this comes after Bahoken, Françoise (2016), Contribution à la cartographie d'une matrice de flux, Thèse en Géographie - Siences des territoires, URL : https://halshs.archives-ouvertes.fr/tel-01273776.
See also: Tribute to Tobler(TTT)/Flowmapper - Work in progress