Learn R Programming

cartography (version 1.0)

getTiles: Get Tiles from Open Map Servers

Description

Get map tiles based on a Spatial*DataFrame extent. Maps can be fetched from various open map servers.

Usage

getTiles(spdf, type = "osm", zoom = NULL)

Arguments

spdf
a Spatial*DataFrame with a valid projection attribute.
type
the tile server from which to get the map, one of "osm", "osm-bw", "maptoolkit-topo", "waze", "mapquest", "mapquest-aerial", "bing", "stamen-toner", "stamen-terrain", "stamen-watercolor", "osm-german", "osm-wanderreitkarte", "mapbox", "esri", "esri-topo",
zoom
the zoom level. If null, it is determined automatically (see Details).

Value

  • An OpenStreetMap object is returned.

Details

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

See Also

tilesLayer

Examples

Run this code
data("nuts2006")
# Download the tiles, nuts0.spdf extent
EuropeOsm <- getTiles(spdf = nuts0.spdf, type = "osm")
class(EuropeOsm)
# Plot the tiles
tilesLayer(EuropeOsm)
# Plot countries
plot(nuts0.spdf, add=TRUE)
# Map tiles sources
mtext(text = "Map data © OpenStreetMap contributors, under CC BY SA.",
      side = 1, adj = 0, cex = 0.7, font = 3)

Run the code above in your browser using DataLab