Learn R Programming

mapboxapi (version 0.5.3)

get_vector_tiles: Retrieve vector tiles from a given Mapbox tileset

Description

Retrieve vector tiles from a given Mapbox tileset

Usage

get_vector_tiles(tileset_id, location, zoom, access_token = NULL)

Value

A list of sf objects representing the different layer types found in the requested vector tiles.

Arguments

tileset_id

The name of the tileset ID; names can be retrieved from your Mapbox account

location

The location for which you'd like to retrieve tiles. If the input is an sf object, the function will return data for all tiles that intersect the object's bounding box. If the input is a coordinate pair or an address, data will be returned for the specific tile that contains the input.

zoom

The zoom level of the request; larger zoom levels will return more detail but will take longer to process.

access_token

A Mapbox access token; which can be set with mb_access_token().

Examples

Run this code
if (FALSE) {

library(mapboxapi)
library(ggplot2)

vector_extract <- get_vector_tiles(
  tileset_id = "mapbox.mapbox-streets-v8",
  location = c(-73.99405, 40.72033),
  zoom = 15
)

ggplot(vector_extract$building$polygons) +
  geom_sf() +
  theme_void()
}

Run the code above in your browser using DataLab