The goal of drawmap is to draw maps in R easily. The package provides a simple interface to draw maps with a uniform style, and is particularly useful for drawing maps with multiple layers, such as countries, regions, and points of interest. The package provides the following functions:
-
draw(): Draw a map. -
load_maps_data(): Load map data usingmaps::map(). -
load_coordinates(): Load points of interest coördinates from a CSV file. -
browse_wfsdata(): Browse data from a Web Feature Service (WFS) endpoint. -
load_wfsdata(): Load data from a Web Feature Service (WFS) endpoint. -
get_map_data(): Retrieve geospatial data via a URL service (used inload_wfsdata()). -
merge_sf(): Mergesfobjects from a specified folder. -
harmonise_vars(): Harmonise specified variables acrosssfobjects. -
theme_map(): Specifyggplot2custom theme fordrawmap::draw()(font and size).
The package is built on top of the ggplot2 and sf packages. It accepts different types of spatial data, such as sf objects and data.frame objects with longitude and latitude columns.
Installation
You can install the development version of drawmap from GitHub with pak::pak() or remotes::install_github():
# Using `pak`:
# install.packages("pak")
pak::pak("EirikTengesdal/drawmap")
# Using `remotes`:
# install.packages("remotes")
remotes::install_github("EirikTengesdal/drawmap")Example
library(drawmap)
norway <- load_maps_data(countries = "Norway")
europe <- load_maps_data()
p <- draw(
area_data = norway,
area_col = "#512888",
area_fill = "#D4C2ED",
other_areas_data = europe,
other_areas_col = "#ADB0B8",
other_areas_fill = "#D9DCE6",
annotation_scale = FALSE
)This yields a map like the one used in the drawmap package logo:

Author
Eirik Tengesdal
Assistant Professor of Norwegian
Department of Early Childhood Education (BLU)
OsloMet – Oslo Metropolitan University
eirik.tengesdal@oslomet.no
Guest Researcher and PhD Student
Department of Linguistics and Scandinavian Studies (ILN)
University of Oslo
eirik.tengesdal@iln.uio.no
ORCID iD: 0000-0003-0599-8925
