Wrapper function for mapboxapi::static_mapbox()
, get_location()
, and
get_osm_data()
, get_osm_id()
, or get_osm_boundaries()
functions.
Usage
get_static_mapbox(
location,
dist = NULL,
unit = "meter",
overlay_location = TRUE,
style_url = "mapbox://styles/mapbox/light-v10",
overlay_sf = NULL,
overlay_style = NULL,
zoom = NULL,
width = 600,
height = 400,
bearing = NULL,
pitch = NULL
)
get_osm_static_mapbox(
id = NULL,
key = NULL,
level = NULL,
location = NULL,
dist = NULL,
unit = "meter",
overlay_location = TRUE,
style_url = "mapbox://styles/mapbox/light-v10",
overlay_sf = NULL,
overlay_style = NULL,
zoom = NULL,
width = 600,
height = 400,
bearing = NULL,
pitch = NULL,
...
)
get_location_static_mapbox(
type,
dist = NULL,
unit = "meter",
name = NULL,
name_col = "name",
id = NULL,
id_col = "id",
location = NULL,
index = NULL,
union = FALSE,
overlay_location = TRUE,
style_url = "mapbox://styles/mapbox/light-v10",
overlay_sf = NULL,
overlay_style = NULL,
zoom = NULL,
width = 600,
height = 400,
bearing = NULL,
pitch = NULL
)
Arguments
- location
An input location for which you would like to request tiles. Can be a length-4 vector representing a bounding box, or an
sf
object. If an inputsf
object is supplied, use thebuffer_dist
argument to control how much area you want to capture around the layer. While the inputsf
object can be in an arbitrary coordinate reference system, if a length-4 bounding box vector is supplied instead it must represent WGS84 longitude/latitude coordinates and be in the orderc(xmin, ymin, xmax, ymax)
.- dist
Buffer distance passed to buffer_dist parameter of
mapboxapi::static_mapbox()
.- unit
Unit of
dist
argument.dist
is converted fromunit
to meters formapboxapi::static_mapbox()
.- overlay_location
If
TRUE
, use the location (or OpenStreetMap feature) as the overlay_sf parameter.- style_url
Style URL; defaults to "mapbox://styles/mapbox/light-v10"
- overlay_sf
The overlay
sf
object (optional). The function will convert thesf
object to GeoJSON then plot over the basemap style. Spatial data that are too large will trigger an error, and should be added to the style in Mapbox Studio instead.- overlay_style
A named list of vectors specifying how to style the sf overlay. Possible names are "stroke", "stroke-width", "stroke-opacity", "fill", and "fill-opacity". The fill and stroke color values should be specified as six-digit hex codes, and the opacity and width values should be supplied as floating-point numbers.
- zoom
The map zoom. The map will infer this from the overlay unless longitude, latitude, and zoom are all specified.
- width, height
Map width and height; defaults to 600 px width and 400 px height.
- pitch, bearing
The map pitch and bearing; defaults to
NULL
. pitch can range from 0 to 60, and bearing from 0 to 360.- id
OpenStreetMap feature id
- key
Feature key for overpass API query.
- level
administrative level (admin_level) of boundary to return; defaults to
NULL
. See https://wiki.openstreetmap.org/wiki/Key:admin_level for more information. Only used for get_osm_boundaries.- ...
Additional parameters passed to get_location_data if type is character and index is
NULL
.- type
For get_osm_static_mapbox, type of feature with id; ("node", "way", or "relation"); for get_location_static_mapbox, type of location (see
get_location()
for details.- name
Location name to return.
- name_col
Column name in type with name values, Default: 'name' Required if name provided.
- id_col
Column name in type with id values, Default: 'id'. Required if id is provided.
- index
Optional list used to match type to data, Default:
NULL
- union
If
TRUE
, the location geometry is unioned with sf::st_union and the names are combined into a single value. Default:FALSE
.
Details
For get_osm_static_mapbox, the ... parameters are passed to the
get_osm_data()
, get_osm_id()
, or get_osm_boundaries()
functions.
Examples
get_osm_static_mapbox(
id = "way/49664223",
dist = 0.5,
unit = "mi",
overlay_style = list(
stroke = "darkgreen",
fill = "green",
fill_opacity = 0.25
)
)
#> # A tibble: 1 × 7
#> format width height colorspace matte filesize density
#> <chr> <int> <int> <chr> <lgl> <int> <chr>
#> 1 PNG 600 400 sRGB FALSE 0 72x72
nc <- read_sf_path(system.file("shape/nc.shp", package = "sf"))
get_location_static_mapbox(
type = nc,
name = "Ashe",
name_col = "NAME",
dist = 50,
unit = "mi"
)
#> # A tibble: 1 × 7
#> format width height colorspace matte filesize density
#> <chr> <int> <int> <chr> <lgl> <int> <chr>
#> 1 PNG 600 400 sRGB FALSE 0 72x72