useR! 2021 - 2021/07/06

A minimal number of well-known dependencies

mf_map()

mf_map() is the main function of the package.

mf_map(x = sf_object, 
       var = "variable", 
       type = "map type", 
       ...)

Map types

Map types

?mf_map()

Map layout

Example

mtq <- mf_get_mtq()
# 
# 
#        
# 
# 
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro")
#         
#       
#        
#        
#        
#        
# 
# 
# 
# 
# 
# 
# 
# 
# 
#

Example

mtq <- mf_get_mtq()
# 
# 
#        
# 
# 
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2, 
       leg_pos = "topright")     
#        
# 
# 
# 
# 
# 
# 
#
# 
# 

Example

mtq <- mf_get_mtq()
# 
# 
#        
# 
# 
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2,
       leg_pos = "topright")     
# 
# 
# 
#
# 
# Plot a layout elements
mf_title("Wealth in Martinique, 2015")
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
mf_scale(size = 5)
mf_arrow('topleft')

Example

mtq <- mf_get_mtq()
# Start a map using a theme  
mf_init(x = mtq, theme = "dark")
#     
# 
# 
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2,
       leg_pos = "topright", 
       add = TRUE)     
# 
# 
#
# 
# Plot a layout elements
mf_title("Wealth in Martinique, 2015")
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
mf_scale(size = 5)
mf_arrow('topleft')

Example

mtq <- mf_get_mtq()
# Start a map using a theme  
mf_init(x = mtq, theme = "dark")
#     
# Plot a shadow
mf_shadow(mtq, col = "grey10", add = TRUE)
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2,
       leg_pos = "topright", 
       add = TRUE)     
# 
# 
#
# 
# Plot a layout elements
mf_title("Wealth in Martinique, 2015")
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
mf_scale(size = 5)
mf_arrow('topleft')

Example

mtq <- mf_get_mtq()
# Start a map using a theme  
mf_init(x = mtq, theme = "dark")
#     
# Plot a shadow
mf_shadow(mtq, col = "grey10", add = TRUE)
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2,
       leg_pos = "topright", 
       add = TRUE)     
# Add an inset world map
mf_inset_on(x = "worldmap", pos = "right")
mf_worldmap(mtq, col = "#0E3F5C")
mf_inset_off()
# Plot a layout elements
mf_title("Wealth in Martinique, 2015")
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
mf_scale(size = 5)
mf_arrow('topleft')

Examples

mtq <- mf_get_mtq()
# Start a map using a theme and extra margins 
mf_init(x = mtq, theme = "dark",
        expandBB = c(0,0,0,.3)) 
# Plot a shadow
mf_shadow(mtq, col = "grey10", add = TRUE)
# Plot a choropleth map
mf_map(x = mtq, var = "MED", type = "choro",
       pal = "Dark Mint", 
       breaks = "quantile", 
       nbreaks = 6, 
       leg_title = "Median Income\n(euros)", 
       leg_val_rnd = -2,
       leg_pos = "topright",
       add = TRUE)
# Add an inset world map
mf_inset_on(x = "worldmap", pos = "right")
mf_worldmap(mtq, col = "#0E3F5C")
mf_inset_off()
# Plot a layout elements
mf_title("Wealth in Martinique, 2015")
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
mf_scale(size = 5)
mf_arrow('topleft')

Pipe(s)

mf_theme("green", line = 1, cex = 0.8)
mtq |>
  mf_map() |>
  mf_map("POP", "prop")
mf_title("Population")

library(magrittr)
mf_theme("agolalight")
mtq %>% 
  mf_map() %>%
  mf_map(c("POP","MED"), "prop_choro") 
mf_title("Population and Wealth")

Insets

mf_map(mtq)
mf_inset_on(x = mtq[1, ], cex = .3)
mf_map(mtq[1, ])
mf_inset_off()

mf_map(mtq)
mf_inset_on(x = "worldmap", pos = "bottomleft")
mf_worldmap(x = mtq)
mf_inset_off()

Themes

https://riatelab.github.io/mapsf/

Vignettes

Thank You