---
title: "Basic Maps"
author: "Mark Padgham"
date: "`r Sys.Date()`"
#output: rmarkdown::pdf_document
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Basic Maps}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

`osmplotr` enables OpenStreetMap (OSM) data to be downloaded (using the
[overpass API](https://overpass-api.de)) and used to produce highly customisable
maps. This vignette demonstrates both data downloading and the creation of
simple maps. The subsequent vignette ('data-maps') demonstrates how
`osmplotr` enables user-defined data to be visualised using OSM data.  The maps
in this vignette represent a small portion of central London, U.K. 


## Contents

[1. Introduction](#1 intro)

[2. Downloading Data](#2 downloading)

[&nbsp;&nbsp;&nbsp;&nbsp;2.1 Negation](#2.1 negation)

[&nbsp;&nbsp;&nbsp;&nbsp;2.2 Additional `key-value` pairs](#2.2 keyval-pairs)

[&nbsp;&nbsp;&nbsp;&nbsp;2.3 A note on rivers](#2.3 rivers)

[&nbsp;&nbsp;&nbsp;&nbsp;2.4 Downloading with `osm_structures` and `make_osm_map`](#2.4 downloading2)

[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.4.1 The `london` data of `osmplotr`](#2.4.1 london-data)

[&nbsp;&nbsp;&nbsp;&nbsp;2.5 Downloading connected highways](#2.5 highways)

[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.5.1 `connect_highways` in detail](#2.5.1 highways-detail)

[3. Producing maps](#3 maps)

[&nbsp;&nbsp;&nbsp;&nbsp;3.1 Saving Maps](#3.1 saving-maps)

[&nbsp;&nbsp;&nbsp;&nbsp;3.2 Plotting different OSM Structures](#3.2 osm-structures)

[&nbsp;&nbsp;&nbsp;&nbsp;3.3. Automating map production](#3.3 make-osm-map)

[&nbsp;&nbsp;&nbsp;&nbsp;3.4 Axes](#3.4 axes)


## <a name="1 intro"></a>1. Introduction

A map can be generated using the following simple steps:
```{r load, eval=FALSE}
library (osmplotr)
library (maptools) # Needed for this vignette
```
```{r, echo=FALSE, message=FALSE}
library (maptools) 
```
```{r, echo=FALSE, message=FALSE}
setwd ('../..')
devtools::load_all ('osmplotr', export_all=FALSE)
setwd ('./osmplotr/vignettes')
```

```{r, echo=FALSE, message=FALSE}
# Combining (dat_B, dat_BC) and (dat_H, dat_HP) requires removing the repeated
# objects
indx <- which (!london$dat_BR$id %in% london$dat_BNR$id)
dat_B <- maptools::spRbind (london$dat_BR [indx,], london$dat_BNR)
indx <- which (!london$dat_H$id %in% london$dat_HP$id)
dat_H <- maptools::spRbind (london$dat_H [indx,], london$dat_HP)
dat_T <- london$dat_T
```
1. Specify the bounding box for the desired region
```{r}
bbox <- get_bbox (c(-0.13,51.50,-0.11,51.52))
```
2. Download the desired data---in this case, all building perimeters.
```{r, eval=FALSE}
dat_B <- extract_osm_objects (key='building', bbox=bbox)
```
3. Initiate an `osm_basemap` with desired background (`bg`) colour
```{r map1}
map <- osm_basemap (bbox=bbox, bg='gray20')
```
4. Add desired plotting objects in the desired colour.
```{r}
map <- add_osm_objects (map, dat_B, col='gray40')
```
5. Print the map
```{r, eval=FALSE}
print_osm_map (map)
```
```{r map1-print, echo=FALSE}
print_osm_map (map, filename='map_a1.png', width=600, units='px', dpi=72)
```
![](map_a1.png)

The function `print_osm_map` creates a graphics device that is scaled to the
bounding box of the map.  Note also that `osmplotr` maps contain no margins and
fill the entire plot area.  Additional capabilities of `osmplotr` are described
in the following sections, beginning with downloading and extraction of data.

## <a name="2 downloading"></a>2. Downloading Data

The main function for downloading OSM data from the 
[overpass API](https://overpass-api.de) is `extract_osm_objects`. Data of a
particular type can be extracted by passing the appropriate OSM `key`, as in the
above example:
```{r, eval=FALSE}
bbox <- get_bbox (c(-0.13,51.51,-0.11,51.52))
dat_B <- extract_osm_objects (key='building', bbox=bbox)
dat_H <- extract_osm_objects (key='highway', bbox=bbox)
```
These objects are of appropriate `Spatial` classes:
```{r}
class (dat_B); class (dat_H)
```
The `SpatialPolygonsDataFrame` and `SpatialLinesDataFrame`
of London buildings and highways respectively
contain 
```{r}
length (dat_B); length (dat_H)
```
... 2,178 building polygons and 2,139 highway lines.  `extract_osm_objects` also
accepts `key-value` pairs which are passed to the
[overpass API](https://overpass-api.de) :
```{r, eval=FALSE}
dat_T <- extract_osm_objects (key='natural', value='tree', bbox=bbox)
```
Trees are located by single coordinates and are thus `SpatialPoints`:
```{r}
class (dat_T); length (dat_T)
```

## <a name="2.1 negation"></a>2.1 Negation

Negation can be specified by pre-pending `!` to the `value` argument so that,
for example, all `natural` objects that are **not** trees can be extracted with
```{r, eval=FALSE}
dat_NT <- extract_osm_objects (key='natural', value='!tree', bbox=bbox)
```
`london$dat_H` contains all non-primary highways, and was extracted with,
```{r, eval=FALSE}
dat_H <- extract_osm_objects (key='highway', value='!primary', bbox=bbox)
```

## <a name="2.2 keyval-pairs"></a>2.2 Additional `key-value` pairs

Any number of `key-value` pairs may be passed to `extract_osm_objects`. For
example, a named building can be extracted with
```{r, eval=FALSE}
extra_pairs <- c ('name', 'Royal.Festival.Hall')
dat <- extract_osm_objects (key='building', extra_pairs=extra_pairs, 
                                       bbox=bbox)
```
This data is stored in `london$dat_RFH`. Note that periods or dots are used for
whitespace, and in fact symbolise (in `grep` terms) any character whatsoever.
The polygon of a building at a particular street address can be extracted with
```{r, eval=FALSE}
extra_pairs <- list (c ('addr:street', 'Stamford.St'),
                     c ('addr:housenumber', '150'))
dat <- extract_osm_objects (key='building', extra_pairs=extra_pairs, 
                                      bbox=bbox)
```
This data is stored as `london$dat_ST`.  Note that addresses generally require
combining both `addr:street` with `addr:housenumber`.

## <a name="2.3 rivers"></a>2.3 A note on rivers

OSM objects are extracted within `R` through using the `osmar` package which
does not currently handle the extraction of rivers in a failsafe way. Rivers are
generally defined by `(key,value)=('waterway','riverbank')`, with relations
returned as an OSM `multipolygon`. These `multipolygon` objects are, however,
**not** extracted by `osmar` when they extend beyond a requested `bbox`, and
there is no way to know in advance whether or not that may be the case. This
requests to download river polygons may not yield the desired results.  This
problem will be addressed in future releases of `osmplotr`.

## <a name="2.4 downloading2"></a>2.4 Downloading with `osm_structures` and `make_osm_map`

The functions `osm_structures` and `make_osm_map` aid both downloading multiple
OSM data types and plotting (with the latter described below).  `osm_structures`
returns a `data.frame` of OSM structure types, associated `key-value` pairs,
unique suffices which may be appended to data structures for storage purposes,
and suggested colours. Passing this list to `make_osm_map` will return a list of
the requested OSM data items, named through combining the `dat_prefix` specified
in `make_osm_map` and the suffices specified in `osm_structures`.

```{r}
osm_structures ()
```
Many structures are identified by keys only, in which cases the values are empty
strings.
```{r}
osm_structures()$value [1:4]
```
The last row of `osm_structures` exists only to define the background colour of
the map, as explained below 
([3.3. Automating map production](#3.3 make-osm-map)).

The suffices include as many letters as are necessary to represent all unique
structure names.  `make_osm_map` returns a list of two components:

1. `osm_data` containing the data objects passed in the `osm_structures`
   argument. Any existing `osm_data` may also be submitted to `make_osm_map`, in
   which case any objects not present in the submitted data will be
   appended to the returned version. If `osm_data` is not submitted, all objects in
   `osm_structures` will be downloaded and returned.
2. `map` containing the `ggplot2` map objects with layers overlaid according to
   the sequence and colour schemes specified in `osm_structures`

The data specified in `osm_structures` can then be downloaded simply by calling:
```{r, eval=FALSE}
dat <- make_osm_map (structures=osm_structures (), bbox=bbox)
```
```{r, echo=FALSE}
dat1 <- list (dat_BU=NULL, dat_A=NULL, dat_W=NULL, dat_G=NULL,
              dat_N=NULL, dat_P=NULL, dat_H=NULL, dat_BO=NULL, dat_T=NULL)
dat <- list (osm_data=dat1, map=ggplot2::ggplot ())
```
```{r}
names (dat); sapply (dat, class); names (dat$osm_data)
```
The requested data are contained in `dat$osm_data`.  A list of desired structures
can also be passed to this function, for example,
```{r}
osm_structures (structures=c('building', 'highway'))
```
Passing this to `make_osm_map` will download only these two structures.
Finally, note that the example of,
```{r}
osm_structures (structures='grass')
```
demonstrates that `osm_structures` converts a number of common `keys` to
OSM-appropriate `key-value` pairs.

### <a name="2.4.1 london-data"></a>2.4.1 The `london` data of `osmplotr`

To illustrate the use of `osm_structures` to download data, this section
reproduces the code that was used to generate the `london` data object which
forms part of the `osmplotr` package.
```{r}
structures <- c ('highway', 'highway', 'building', 'building', 'building',
                 'amenity', 'park', 'natural', 'tree')   
structs <- osm_structures (structures=structures, col_scheme='dark')   
structs$value [1] <- '!primary'   
structs$value [2] <- 'primary'
structs$suffix [2] <- 'HP'
structs$value [3] <- '!residential'
structs$value [4] <- 'residential'
structs$value [5] <- 'commercial'
structs$suffix [3] <- 'BNR'
structs$suffix [4] <- 'BR'
structs$suffix [5] <- 'BC'
```
Suffices are generated automatically from structure names only, not values, and
the suffices for negated forms must therefore be specified manually.  The
`london` data can then be downloaded by simply calling `make_osm_map`:
```{r, eval=FALSE}
london <- make_osm_map (structures=structs, bbox=bbox)
london <- london$osm_data
```
The requested data are contained in the `$osm_data` list item. `make_osm_map`
also returns a `$map` item which is described below 
(see [3.3. Automating map production](#3.3 make-osm-map)).

## <a name="2.5 highways"></a>2.5 Downloading connected highways

The visualisation functions described in the second `osmplotr` vignette
([Data maps](https://cran.r-project.org/package=osmplotr))
enable particular regions of maps
to be highlighted. While it may often be desirable to highlight regions
according to a user's own data, `osmplotr` also enables regions to be defined by
providing a list of the names of encircling highways. The function which
achieves this is `connect_highways`, which returns a sequential list of
`SpatialPoints` from those segments of the named highways which connected
continuously and sequentially to form a single enclosed space. An example is,
```{r, echo=FALSE}
highways1 <- london$highways1
```
```{r, eval=FALSE}
highways <- c ('Monmouth.St', 'Short.?s.Gardens', 'Endell.St', 'Long.Acre',
               'Upper.Saint.Martin')
highways1 <- connect_highways (highways=highways, bbox=bbox)
```
Note the use of the [regex](https://en.wikipedia.org/wiki/Regular_expression)
character `?` which declares that the previous character is optional. This
matches both "Shorts Gardens" and "Short's Gardens", both of which appear in OSM
data.
```{r}
class (highways1); length (highways1); head (coordinates (highways1))
```
Other examples, which are also included in the provided `london` data, include:
```{r, eval=FALSE}
highways <- c ('Endell.St', 'High.Holborn', 'Drury.Lane', 'Long.Acre')
highways2 <- connect_highways (highways=highways, bbox=bbox)
highways <- c ('Drury.Lane', 'High.Holborn', 'Kingsway', 'Great.Queen.St')
highways3 <- connect_highways (highways=highways, bbox=bbox)
```

The extraction of bounding polygons from named highways is not failsafe, and may
generate various warning messages.  To understand the kinds of conditions under
which it may not work, it is useful to examine `connect_highways` in more
detail.

### <a name="2.5.1 highways-detail"></a>2.5.1 `connect_highways` in detail

`connect_highways` takes a list of OpenStreetMap highways and sequentially
connects closest nodes of adjacent highways until the set of named highways
connects to form a cycle.  Cases where no circular connection is possible
generate an error message. The routine proceeds through the three stages of,

1. Adding intersection nodes to junctions of ways where these don't already
   exist

2. Filling a connectivity matrix between the listed highways and extracting the
   **longest** cycle connecting all of them 

3. Inserting extra connections between highways until the length of the longest
   cycle is equal to `length (highways)`.

However, even once the highways are connected, the individual components of each
highway may not necessarily connect in a continuous manner to complete the
cycle. The final task is thus ensuring that the components of each individual
highway actually connect, through sequentially connecting the closest pairs of
components until a shortest path is possible between the two components which
connect with other highways.

This procedure can not be guaranteed failsafe owing both to the inherently
unpredictable nature of OpenStreetMap, as well as to the unknown relationships
between named highways. To enable problematic cases to be examined and hopefully
resolved, `connect_highways` has a `plot` option:
```{r connect_highways, fig.width=4, message=FALSE, eval=TRUE}
bbox_big <- get_bbox (c(-0.15,51.5,-0.10,51.52))
highways <- c ('Kingsway', 'Holborn', 'Farringdon.St', 'Strand',
               'Fleet.St', 'Aldwych')
highway_list <- connect_highways (highways=highways, bbox=bbox_big, plot=TRUE)
```

The plot depicts each highway in a different colour, along with numbers at start
and end points of each segment. This plot reveals in this case that highway#6
('Aldwych') is actually nested within two components of highway#4 ('Strand').
`connect_highways` searches for the shortest path connecting all named highways,
and since 'Strand' connects to both highways#1 and #5, the shortest path
excludes #6. This exclusion of one of the named components generates the
warning message. 


## <a name="3 maps"></a>3. Producing maps

Maps will generally contain multiple kinds of OSM data, for example,
```{r, eval=FALSE}
dat_B <- extract_osm_objects (key='building', bbox=bbox)
dat_H <- extract_osm_objects (key='highway', bbox=bbox)
dat_T <- extract_osm_objects (key='natural', value='tree', bbox=bbox)
```

As illustrated above, plotting maps requires first making a basemap with a
specified background colour. Portions of maps can also be plotted by creating a
`basemap` with a smaller bounding box.
```{r map2}
bbox_small <- get_bbox (c(-0.13,51.51,-0.11,51.52))
map <- osm_basemap (bbox=bbox_small, bg='gray20')
map <- add_osm_objects (map, dat_H, col='gray70')
map <- add_osm_objects (map, dat_B, col='gray40')
```
`map` is then a `ggplot2` which may be viewed simply by passing it to
`print_osm_map`:
```{r, eval=FALSE}
print_osm_map (map)
```
```{r map2-print, echo=FALSE}
print_osm_map (map, filename='map_a2.png', width=600, units='px', dpi=72)
```
![](map_a2.png)


Other graphical parameters can also be passed to `add_osm_objects`, such as
border colours or line widths and types. For example,
```{r map3, eval=FALSE}
map <- osm_basemap (bbox=bbox_small, bg='gray20')
map <- add_osm_objects (map, dat_B, col='gray40', border='orange', size=0.2)
print_osm_map (map)
```
```{r map3-print, echo=FALSE}
map <- osm_basemap (bbox=bbox_small, bg='gray20')
map <- add_osm_objects (map, dat_B, col='gray40', border='orange', size=0.2)
print_osm_map (map, filename='map_a3.png', width=600, units='px', dpi=72)
```
![](map_a3.png)

The `size` argument is passed to the corresponding `ggplot2` routine for
plotting polygons, lines, or points, and respectively determines widths of lines
(for polygon outlines and for lines), and sizes of points.  The `col` argument
determines the fill colour of polygons, or the colour of lines or points.

```{r map4, eval=FALSE}
map <- add_osm_objects (map, dat_H, col='gray70', size=0.7)
map <- add_osm_objects (map, dat_T, col='green', size=2, shape=1)
print_osm_map (map)
```
```{r map4-print, echo=FALSE}
map <- add_osm_objects (map, dat_H, col='gray70', size=0.7)
map <- add_osm_objects (map, dat_T, col='green', size=2, shape=1)
print_osm_map (map, filename='map_a4.png', width=600, units='px', dpi=72)
```
![](map_a4.png)

Note also that the `shape` parameter determines the point shape, for details of
which see `?ggplot2::shape`. Also note that plot order affects the final
outcome, because components are sequentially overlaid and thus the same map
components plotted in a different order will generally produce a different
result.

## <a name="3.1 saving-maps"></a>3.1 Saving Maps

The function `print_osm_map()` can be used to print either to on-screen
graphical devices or to graphics files (see, for example, `?png` for a list of
possible graphics devices). Sizes and resolutions of devices may be
specified with the appropriate parameters. Device dimensions are scaled by
default to the proportions of the bounding box (although this can be
over-ridden).

A screen-based device simply requires
```{r, eval=FALSE}
print_osm_map (map)
```
while examples of writing higher resolution versions to files include:
```{r, eval=FALSE}
print_osm_map (map, filename="map.png", width=10, units="in", dpi=72)
print_osm_map (map, filename="map.eps", width=1000, units="px", dpi=72)
print_osm_map (map, filename="map", device="jpeg", width=10, units="cm")
```

## <a name="3.2 osm-structures"></a>3.2 Plotting different OSM Structures

The ability demonstrated above to use negation in `extract-osm-objects` allows
different kinds of the same object to be visually contrasted, for example
primary and non-primary highways:

```{r, eval=FALSE}
dat_HP <- extract_osm_objects (key='highway', value='primary', bbox=bbox)
dat_H <- extract_osm_objects (key='highway', value='!primary', bbox=bbox)
```
```{r, echo=FALSE}
dat_HP <- london$dat_HP
dat_H <- london$dat_H
```
```{r map5, eval=FALSE}
map <- osm_basemap (bbox=bbox_small, bg='gray20')
map <- add_osm_objects (map, dat_H, col='gray50')
map <- add_osm_objects (map, dat_HP, col='gray80', size=2)
print_osm_map (map)
```
```{r map5-print, echo=FALSE}
map <- osm_basemap (bbox=bbox_small, bg='gray20')
map <- add_osm_objects (map, dat_H, col='gray50')
map <- add_osm_objects (map, dat_HP, col='gray80', size=2)
print_osm_map (map, filename='map_a5.png', width=600, units='px', dpi=72)
```
![](map_a5.png)

The additional `key-value` pairs demonstrated above (for Royal Festival Hall,
`dat_RFH` and 150 Stamford Street, `dat_ST`) also demonstrated above allow for
highly customised maps in which distinct objects are plotting with different
colour schemes.
```{r, echo=FALSE}
dat_RFH <- london$dat_RFH
dat_ST <- london$dat_ST
```
```{r map7, eval=FALSE}
bbox_small2 <- get_bbox (c (-0.118, 51.504, -0.110, 51.507))
map <- osm_basemap (bbox=bbox_small2, bg='gray95')
map <- add_osm_objects (map, dat_H, col='gray80')
map <- add_osm_objects (map, dat_HP, col='gray60', size=2)
map <- add_osm_objects (map, dat_RFH, col='orange', border='red', size=2)
map <- add_osm_objects (map, dat_ST, col='skyblue', border='blue', size=2)
print_osm_map (map)
```
```{r map7-print, echo=FALSE}
bbox_small2 <- get_bbox (c (-0.118, 51.504, -0.110, 51.507))
map <- osm_basemap (bbox=bbox_small2, bg='gray95')
map <- add_osm_objects (map, dat_H, col='gray80')
map <- add_osm_objects (map, dat_HP, col='gray60', size=2)
map <- add_osm_objects (map, dat_RFH, col='orange', border='red', size=2)
map <- add_osm_objects (map, dat_ST, col='skyblue', border='blue', size=2)
print_osm_map (map, filename='map_a7.png', width=600, units='px', dpi=72)
```
![](map_a7.png)


## <a name="3.3 make-osm-map"></a>3.3. Automating map production

As indicated above 
([2.4 Downloading with `osm_structures` and `make_osm_map`](#2.4 downloading2)),
the production of maps overlaying various type of OSM objects is facilitated
with `make_osm_map`.  The structure of a map is defined by `osm_structures` as
described above.

Producing a map with customised data is as simple as,
```{r map8, eval=FALSE}
structs <- c ('highway', 'building', 'park', 'grass', 'tree')   
structures <- osm_structures (structures=structs, col_scheme='light')   
dat <- make_osm_map (structures=structures, bbox=bbox_small)
map <- dat$map
print_osm_map (map)
```
```{r, echo=FALSE}
structs <- c ('highway', 'building', 'park', 'grass', 'tree')   
structures <- osm_structures (structures=structs, col_scheme='light')   
osm_dat <- list (dat_B=dat_B, dat_H=dat_H, dat_P=london$dat_P,
                 dat_A=london$dat_A, dat_G=london$dat_G, dat_T=london$dat_T)
dat <- make_osm_map (structures=structures, osm_data=osm_dat, bbox=bbox_small)
print_osm_map (dat$map, filename='map_a8.png', width=600, units='px', dpi=72)
```
![](map_a8.png)

Calling `make_osm_map()` downloads the requested structures within the given
`bbox` and returns a list of two components, the first of which contains the
downloaded data:
```{r}
names (dat); names (dat$osm_data)
```

Pre-downloaded data may also be passed to `make_osm_map()`
```{r map9, eval=FALSE}
dat <- make_osm_map (structures=structures, osm_data=dat$osm_data)
print_osm_map (dat$map)
```
```{r map9-print, echo=FALSE}
dat <- make_osm_map (structures=structures, osm_data=osm_dat)
print_osm_map (dat$map, filename='map_a9.png', width=600, units='px', dpi=72)
```
![](map_a9.png)

In this case, because no bounding box was passed to `make_osm_map`, a bounding
box is extracted as the **largest** box spanning all objects in `osm_data`.
These objects include highways which extend beyond the defining bounding box,
and the large park in the south east. The `bbox` argument may simply be passed
to restore this map to the previous version:
```{r map9b, eval=FALSE}
dat <- make_osm_map (structures=structures, osm_data=dat$osm_data,
                     bbox=bbox_small)
```

Objects in maps are overlaid on the plot according to the order of rows in
`osm_structures`, with the single exception that `background` is plotted first.
This order can be readily changed or restricted simply by submitting structures
in a desired order.

```{r}
structs <- c ('amenity', 'building', 'grass', 'highway', 'park')
osm_structures (structs, col_scheme='light')
```


## <a name="3.4 axes"></a>3.4 Axes

Axes may be added to maps using the `add_axes` function. In contrast to many `R`
packages for producing maps, maps in `osmplotr` fill the entire plotting space,
and axes are added *internal* to this space. The separate function for adding
axes allows them to be overlaid on top of all previous layers.

Axes added to a dark version of the previous map look like this:
```{r map10}
structures <- osm_structures (structures=structs, col_scheme='dark')   
dat <- make_osm_map (structures=structures, osm_data=dat$osm_dat,
                     bbox=bbox_small)
map <- add_axes (dat$map, colour='black')
```
Note that, as described above, `make_osm_map` returns a list of two items: (i)
potentially modified data (in `$osm_data`) and (ii) the map object (in `$map`).
All other `add_` functions take a map object as one argument and return the
single value of the modified map object.
```{r, eval=FALSE}
print_osm_map (map)
```
```{r map10-print, echo=FALSE}
print_osm_map (map, filename='map_a10.png', width=600, units='px', dpi=72)
```
![](map_a10.png)

This map reveals that the axes and labels are printed above semi-transparent
background rectangles, with transparency controlled by the `alpha` parameter.
Axes are always plotted on the left and lower side, but positions can be
adjusted with the `pos` parameter which specifies the,

> Positions of axes and labels relative to entire plot device

```{r map11, eval=FALSE}
map <- add_axes (map, colour='blue', pos=c(0.1,0.2),
                      fontsize=5, fontface=3, fontfamily="Times")
print_osm_map (map)
```
```{r map11-print, echo=FALSE}
map <- add_axes (map, colour='blue', pos=c(0.1,0.2),
                      fontsize=5, fontface=3, fontfamily="Times")
print_osm_map (map, filename='map_a11.png', width=600, units='px', dpi=72)
```
![](map_a11.png)

The second call to `add_axes` overlaid additional axes on a map that already had
axes from the previous call.  This call also demonstrates how sizes and other
font characteristics of text labels can be specified.  

Finally, the current version of `osmplotr` does not allow text labels of axes to
be rotated. (This is because the semi-transparent underlays are generated with
`ggplot2::geom_label` which currently prevents rotation.)

Click on the following link to proceed to the second `osmplotr` vignette:
[Data maps](https://cran.r-project.org/package=osmplotr)
