osm.plot: Plot Open Street Map Tiles

Description Usage Arguments Examples

View source: R/osmplot.R

Description

Plot Open Street Map tiles using rasterImage and sp::plot. Define your own tile sources by creating a tile url function in the global environment, although most OSM listed servers are included. See osm.types for types options. By default tiles are plotted in the Spherical Mercator projection (epsg:3857); pass project=FALSE to keep lat/lon coordinates.

Usage

1
2
3
4
osm.plot(bbox, zoomin = 0, zoom = NULL, type = NULL,
  forcedownload = FALSE, stoponlargerequest = TRUE, fusetiles = TRUE,
  cachedir = NULL, res = 150, project = TRUE, progress = c("text",
  "none"), quiet = TRUE, ...)

Arguments

bbox

A bounding box as generated by sp::bbox() or prettymapr::searchbbox()

zoomin

The amount by which to adjust the automatically calculated zoom (or manually specified if the zoom parameter is passed). Use +1 to zoom in, or -1 to zoom out.

zoom

Manually specify the zoom level (not reccomended; adjust zoomin or res instead.

type

A map type; one of that returned by osm.types. User defined types are possible by defining tile.url.TYPENAME <- function(xtile, ytile, zoom){} and passing TYPENAME as the type argument.

forcedownload

TRUE if cached tiles should be re-downloaded. Useful if some tiles are corrupted.

stoponlargerequest

By default osm.plot will only load 32 tiles at a time. If plotting at a higher resolution it may be necessary to pass true here.

fusetiles

TRUE if tiles should be fused into a single image. This is the default because white lines appear between tiles if it is set to FALSE. PDFs appear not to have this problem, so when plotting large, high resolution PDFs it may be faster (and more memory efficient) to use fusetiles=FALSE.

cachedir

The directory in which tiles should be cached. Defaults to getwd()/rosm.cache.

res

The resolution used to calculate scale.

project

TRUE if tiles should be projected to a pseudo-mercator projection, FALSE if lat/lon should be maintained. Becuase sp::plot adjusts the aspect according to latitude for lat/lon coordinates, this makes little difference at high zoom and may make plotting overlays more convenient. Defaults to TRUE.

progress

A progress bar to use, or "none" to suppress progress updates

quiet

Pass FALSE to see more error messages, particularly if your tiles do not download/load properly.

...

Additional parameters to be passed on to the first call to sp::plot

Examples

1
2
3
4
5
library(prettymapr)
ns <- makebbox(47.2, -59.7, 43.3, -66.4)
osm.plot(ns)
osm.plot(ns, type="stamenbw")
prettymap(osm.plot(ns), scale.style="ticks", scale.tick.cex=0)

paleolimbot/rosm documentation built on July 23, 2019, 7:35 a.m.