FOSS4G 2021 - 2021/09/30

Typical workflow

mf_map()

mf_map() is the main function of the package.

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

?mf_map()

9 map types - Vignette

9 map types - Vignette

Map layout

Example

mtq <- mf_get_mtq()
# 
# 
#        
# 
# 
# Plot the base map
mf_map(x = mtq)
#         
#       
#        
#        
#        
#        
# 
# 
# 
# 
# 
# 
# 
# 
# 
#

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')

Example

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')

Insets - Vignette

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

Insets - Vignette

Themes - Vignette

Raster

library(maptiles)
osm <- get_tiles(
  x = mtq,
  provider = "Stamen.TerrainBackground", 
  crop= TRUE, zoom = 11
)
mf_theme("default", bg = "#99b3cc")
mf_raster(osm)
mf_map(mtq, border = "tomato4", col = NA, 
       add = TRUE)
mf_scale()
mf_title("mf_raster()")
mf_credits(
  txt = get_credit("Stamen.TerrainBackground")
)







New!

library(mapsf)
mtq <- mf_get_mtq()
mf_init(mtq)
mf_background("img/blackboard.jpg")
mf_map(mtq, lwd = 3, col = NA, 
       border = "white", add = TRUE)
mf_credits(
  txt = "Photo by Noita Digital on Unsplash",
  col = "white"
)
mf_title("mf_background()")



Next features

  • Legends for rasters (continuous, classes, categories)

  • Horizontal layout for legends

  • You tell me!

Development

A minimal number of well-known dependencies

Development

riatelab.github.io/mapsf

Thank You