Create tiles for a spatial dataset.

tiles(x, ...)

# S3 method for default
tiles(x, ...)

# S3 method for RasterLayer
tiles(x, output_dir, colors = "Spectral",
  zoom = "5-16", threads = 1, project = TRUE, verbose = FALSE,
  cache = TRUE, shiny = FALSE, ...)

Arguments

x

RasterLayer-class object.

...

not used.

output_dir

character directory in which to save tiles.

colors

The color palette (see colorNumeric) or function to use to color the raster values (hint: if providing a function, set na.color to "#00000000" to make NA areas transparent). Defaults to "Spectral".

zoom

character Zoom levels to render. The levels can be specified as a single number (e.g "10") or as a range (e.g. "1-10"). Defaults to "5-16".

threads

numeric number of threads to use for processing. Defaults to 1.

project

logical If argument to x is not already in the coordinate reference system expected by Leaflet (Mercator; EPSG:3857), should the data be automatically reprojected? If argument to project is FALSE, then the user will need to ensure that the data is in the correct coordinate reference system.

verbose

logical Should information be printed during processing?

cache

logical if tiles already exist in argument to output_dir should the processing be skipped?

shiny

logical are the tiles being served in a shiny applications?

Value

character tile scheme.

Details

This function creates a tile layer, following the Tile Map Service specification, using the object in argument to x and saves it in the argument to output_dir.

See also

addTiles.

Examples

# load leafleat library(leaflet) # load example data set data(netherlands, package = "mapmisc") # create leaflet map and visualize data using tiles map <- leaflet() %>% setView(lng = 5.75560, lat = 50.94723, zoom = 12) %>% addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% addTiles(tiles(nldElev, output_dir = tempdir(), zoom = "10-16"), group = "Elevation", options = tileOptions(minZoom = 5, maxZoom = 16, tms = TRUE)) %>% addLayersControl(baseGroups = "Basemap", overlayGroups = "Elevation", options = layersControlOptions(collapsed = FALSE)) # render map print(map)