install.packages(c("sf", "terra", "dplyr", "spData", "tmap", "tmap.mapgl"))Main map layers
| Function | Geometry | Map variables |
|---|---|---|
| tm_polygons() | polygons | fill, fill_alpha, col, col_alpha, lwd, lty |
| tm_symbols() | points, polygons, and lines | size, shape, fill, fill_alpha, col, col_alpha, lwd |
| tm_lines() | lines | col, col_alpha, lwd, lty |
| tm_text() | points, polygons, and lines | text, size, col, col_alpha, fontface |
| tm_raster() | raster | col, col_alpha |
Each map layer can be constant or data-driven.
If data-driven, you may use .scale and .legend, for example, fill.scale and fill.legend in tm_polygons().









