Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fbahoken/cartogRaflow
Tips and tricks for flow and movement mapping
https://github.com/fbahoken/cartogRaflow
Last synced: 3 months ago
JSON representation
Tips and tricks for flow and movement mapping
- Host: GitHub
- URL: https://github.com/fbahoken/cartogRaflow
- Owner: fbahoken
- License: mit
- Created: 2015-08-02T21:47:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-14T12:01:03.000Z (about 3 years ago)
- Last Synced: 2024-05-21T02:10:33.405Z (6 months ago)
- Language: R
- Homepage:
- Size: 8.22 MB
- Stars: 14
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cartograflow
**Filtering origin-destination Matrices for Thematic Flowmapping**[![](https://www.r-pkg.org/badges/version/cartograflow)](https://cran.r-project.org/package=cartograflow)
[![](https://cranlogs.r-pkg.org/badges/cartograflow?color=brightgreen)](https://cran.r-project.org/package=cartograflow)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`).
# Installation
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")`# Follow-up of updates
_**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
# Available vignettes
[\Vignette : rmd and html](https://github.com/fbahoken/cartogRaflow/blob/master/vignettes/)[Vignette cartograflow general presentation - CRAN version 1.0.3](http://fbahoken.github.io/cartogRaflow/)
[subVignette : cartograflow concentration - v. 1.0.2](https://github.com/fbahoken/cartogRaflow/tree/master/vignettes/cartograflow_concentration.html)
[subVignette : cartograflow distance - v. 1.0.2](https://github.com/fbahoken/cartogRaflow/tree/master/vignettes/cartograflow_distance.html)
[subVignette : cartograflow ordinal distance - v. 1.0.2](https://github.com/fbahoken/cartogRaflow/tree/master/vignettes/cartograflow_ordinal_distance.hmtl)# List of functions
## 1. Handling flow data
#### 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 bilateral flows (on Fij)
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 diagonalFor x = "bibal": (or for antisymetric matrix)
net = "positive" for extracting the positive flow values
net = "negative" for extracting the negative flow values.#### 1.3. Computing flows places oriented indicators (on i or on j)
`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.## 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()` for computing a flow filter based on _a double criterion for selecting flows_ before mapping.
See : [subVignette : cartograflow concentration](https://github.com/fbahoken/cartogRaflow/blob/master/vignettes/cartograflow_concentration.html)
#### 2.2. Distance travelled
See : [subVignette : cartograflow distance](https://github.com/fbahoken/cartogRaflow/blob/master/vignettes/cartograflow_distance.html)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**
See : [subVignette : cartograflow ordinal distance](https://github.com/fbahoken/cartogRaflow/tree/master/vignettes/cartograflow_ordinal_distance.hmtl)`flowcontig()` is to compute an _ordinal distance_ matrice based on a k-contiguity matrice.
## 3. Reducing an OD 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. for `k` 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 selected `dmin` or `dmax` criteria.See : [subVignette : cartograflow distance](https://github.com/fbahoken/cartogRaflow/blob/master/vignettes/cartograflow_distance.html)
## 4. Flow mapping
`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](https://github.com/tributetotobler/ttt) - Work in progress