Learn R Programming

cartography (version 2.2.1)

getTiles: Get Tiles from Open Map Servers

Description

Get map tiles based on a spatial object extent. Maps can be fetched from various open map servers.

Usage

getTiles(x, spdf, type = "osm", zoom = NULL, crop = FALSE,
  verbose = FALSE)

Arguments

x

an sf object, a simple feature collection or a Spatial*DataFrame.

spdf

deprecated, a Spatial*DataFrame with a valid projection attribute.

type

the tile server from which to get the map, one of "osm", "hotstyle", "hikebike", "osmgrayscale", "stamenbw", "stamenwatercolor", "cartodark", "cartolight".

zoom

the zoom level. If null, it is determined automatically (see Details).

crop

TRUE if results should be cropped to the specified x extent, FALSE otherwise.

verbose

if TRUE a progress bar is displayed.

Value

A RatserBrick is returned.

Details

Zoom levels are described on the OpenStreetMap wiki: http://wiki.openstreetmap.org/wiki/Zoom_levels.

See Also

tilesLayer

Examples

Run this code
# NOT RUN {
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
# Download the tiles, extent = Martinique
mtqOSM <- getTiles(x = mtq, type = "osm", crop = TRUE)
# Plot the tiles
tilesLayer(mtqOSM)
# Plot countries
plot(st_geometry(mtq), add=TRUE)
txt <- "<U+00A9> OpenStreetMap contributors. Tiles style under CC BY-SA, www.openstreetmap.org/copyright"
mtext(text = txt, side = 1, adj = 0, cex = 0.7, font = 3)
# }

Run the code above in your browser using DataLab