Learn R Programming

Cartograflow

Filtering Matrices for Thematic Flowmapping - Dealing with "spaghetti-effect"

This package is designed to create the so-called flowmaps, thematic origin-destination (OD) maps by filtering matrices. It is based on different functions that are mainly used to prepare the flow dataset. Complementary packages are for the spatial objects processing with{sp} or {sf} and for the mapping purposes from{Cartography} except particular cases.

List of functions

1. Preparing flow dataset

1.1. Pre-processing

-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.

1.2. Computing flows

It is to decide firstly to zero or not the diagonal, see {base::diag}.

-flowtype() is to compute the main types of flows from an asymmetric flow dataset (matrice or long format). The result is a bilateral gross or bilateral net flows matrice. It is also possible to compute the matrice's margins in order to calculate probabilities of sending and receiving flows or all kinds of indicators. Use for that the R {base} or {dplyr}.

2. Flow analysis

2.1. Concentration

-flowgini() performs a concentration analysis of a flow dataset - To be use before flowanalysis() Computes Gini coefficient and plot Lorenz curve

-flowanalysis() is to be used after flowgini() for computing a flow filter based on a double criterion for selecting flows before mapping :

  • level of flow thresholding, and the corresponding filter ;
  • desired threshold level of flow's information significativity (% of total of flow information) ;

or

  • desired threshold level of flow's features density (% of total features).

2.2. Distance travelled

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 use flowdist() 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

-flowcontig() compute an ordinal distance distance matrice based on a k-contiguity matrice. (k) is the order parameter, the number of borders to be crossed between origins and destinations places. Use after flowreduct() and directly flowmap()without applying the filter parameter. It is possible to map firstly the k-order neighbourhood spatial graph using flowmap() without applying the filter parameter.

2.2.3. Reducting a flow matrice by an external matrice

-flowreduct() is to perform the reduction of the flow dataset according to another matrice (especially a matrice distance)

3. Flow mapping

-flowmap() is to create a layer of lines and plot them, using a flow dataset and a spatial shape.


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.

Copy Link

Version

Install

install.packages('cartograflow')

Monthly Downloads

610

Version

1.0.3

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Sylvain Blondeau

Last Published

July 19th, 2020

Functions in cartograflow (1.0.3)

flowcontig

Builds an ordinal distance matrices from a spatial features background
flows

MOBPRO: Commuting trips in 2015
flowreduct

Flow matrix reduction according to another matrix
mat_ex

Example of a small matrice
flowtabmat

Changing the format of a flow dataset
flowstructmat

Structuring a matrix
flowtype

Compute bilateral several flow types
geoid

Geographical ID
flowgini

Analysis of flow concentration (Gini coefficient)
flowdist

Builds a continuous distance matrices from a spatial features background
flowanalysis

Computation of a global concentration criterion of flows values or features
cartograflow

Cartograflow Package
flowcarre

Builds a square matrice from geographical nodes
flowplaces

Computes flow indicators per places
flowmap

Mapping of an origin-destination flow matrix
flowlowup

Extracts the triangular sub-matrix of flows
flowjointure

Builds a spatial join with a flow dataset