map_bidev: Map Multiscalar Typology (2 deviations)

View source: R/map_bidev.R

map_bidevR Documentation

Map Multiscalar Typology (2 deviations)

Description

Compute the multiscalar typology (2 deviations) and propose colors for mapping the results.

Usage

map_bidev(x, dev1, dev2, breaks = c(25, 50, 100), xid = NULL)

Arguments

x

A sf object including a variable resulting from the mst function.

dev1

column name of the first relative deviation in x.

dev2

coumn name of the second relative deviation in x.

breaks

Distance to the index 100 (average of the context), in percentage. A vector of three values. Defaut c(25,50,100). 25 to indexes 80 and 125. 50 and 200.

xid

identifier field in x. Default the first column.

Value

A list including a ordered sf object for mapping mst column (geom) and a vector of suggested colors (cols).

bidev typology values :

  • ZZ: Near the average for the two selected deviation

  • A1: Above the average for dev1 and dev2, distance to the avarage : +

  • A2: Above the average for dev1 and dev2, distance to the avarage : ++

  • A3: Above the average for dev1 and dev2, distance to the avarage : +++

  • B1: Above the average for dev1 and below for dev2, distance to the avarage : +

  • B2: Above the average for dev1 and below for dev2, distance to the avarage : ++

  • B3: Above the average for dev1 and below for dev2, distance to the avarage : +++

  • C1: Below the average for dev1 and dev2, distance to the avarage : +

  • C2: Below the average for dev1 and dev2, distance to the avarage : ++

  • C3: Below the average for dev1 and dev2, distance to the avarage : +++

  • D1: Below the average for dev1 and above for dev2, distance to the avarage : +

  • D2: Below the average for dev1 and above for dev2, distance to the avarage : ++

  • D3: Below the average for dev1 and above for dev2, distance to the avarage : +++

Examples

# Focus on exceptional values (50, 100 and 200 % above-under the average)
# Load data
library(sf)
com <- st_read(system.file("metroparis.gpkg", package = "MTA"), layer = "com", quiet = TRUE)
ept <- st_read(system.file("metroparis.gpkg", package = "MTA"), layer = "ept", quiet = TRUE)

# Prerequisite  - Compute 2 deviations
com$gdev <- gdev(x = com, var1 = "INC", var2 = "TH")
com$tdev <- tdev(x = com, var1 = "INC", var2 = "TH", key = "EPT")

# Compute map_bidev
bidev <- map_bidev(x = com, dev1 = "gdev", dev2 = "tdev", breaks = c(50, 100, 200))

# Unlist resulting function
com <- bidev$geom
cols <- bidev$cols

#Visualization
# One side for the map, another for the plot
opar <- par(mfrow = c(1,2), mar = c(0,4,0,0))

if(require(mapsf)){
# Cartography
mf_map(x = com, var = "bidev", type = "typo", val_order = unique(com$bidev), 
       border = "grey50", pal = cols, lwd = 0.2, leg_pos = NA)
mf_map(ept, col = NA, add = TRUE)

# Label territories in the C3 category
mf_label(x = com[com$bidev == "C3",], var = "LIBCOM", halo = TRUE)

mf_layout(title = "2-Deviations synthesis : general and territorial contexts",
         credits = paste0("Sources: GEOFLA® 2015 v2.1, Apur, impots.gouv.fr",
                          "\nMTA", packageVersion("MTA")),
         arrow = FALSE)

# Add plot_bidev on the right side of the map
plot_bidev(x = com,  dev1 = "gdev",  dev2 = "tdev",
          dev1.lab = "General deviation (MGP Area)",
          dev2.lab = "Territorial deviation (EPT of belonging)",
          breaks = c(50, 100, 200),
          lib.var = "LIBCOM", lib.val = "Clichy-sous-Bois", cex.lab = 0.8)
par(opar)
}

MTA documentation built on Nov. 2, 2023, 5:06 p.m.