Skip to contents

Get information about features in a tileset using the Tilequery API

Usage

query_tiles(
  location,
  tileset_id,
  radius = 0,
  limit = 5,
  dedupe = TRUE,
  geometry = NULL,
  layers = NULL,
  access_token = NULL
)

Arguments

location

The location for which you'd like to query tiles, expressed as either a length-2 vector of longitude and latitude or an address you'd like to geocode.

tileset_id

The tileset ID to query.

radius

The radius around the point (in meters) for which you'd like to query features. For point-in-polygon queries (e.g. "what county is my point located in?") the default of 0 should be used.

limit

How many features to return (defaults to 5). Can be an integer between 1 and 50.

dedupe

Whether or not to return duplicate features as identified by their IDs. The default, TRUE, will de-duplicate your dataset.

geometry

The feature geometry type to query - can be "point", "linestring", or "polygon". If left blank, all geometry types will be queried.

layers

A vector of layer IDs you'd like to query (recommended); if left blank will query all layers, with the limitation that at most 50 features can be returned.

access_token

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

Value

An R list containing the API response, which includes information about the requested features. Parse the list to extract desired elements.

Examples

if (FALSE) { # \dontrun{

library(mapboxapi)

elevation <- query_tiles(
  location = "Breckenridge, Colorado",
  tileset_id = "mapbox.mapbox-terrain-v2",
  layer = "contour",
  limit = 50
)

max(elevation$features$properties$ele)
} # }