mapboxapi
mapboxapi is an R package that interfaces with Mapbox web services APIs. Its purpose is to help R users incorporate the suite of Mapbox tools into their spatial data science projects. Install from CRAN with the following command:
install.packages("mapboxapi")
To get started, sign up for a Mapbox account and generate an access token. Set your public or secret token for use in the package with mb_access_token()
:
library(mapboxapi)
mb_access_token("pk.eyas...", install = TRUE)
Once you’ve set your token, you are ready to get started using the package. The following example integrates Mapbox maps, navigation, and search services to plot a five-minute walking isochrone over an interactive Leaflet map using a Mapbox style:
library(leaflet)
walk_5min <- mb_isochrone("2850 S University Dr, Fort Worth TX 76129",
profile = "walking",
time = 5)
leaflet(walk_5min) %>%
addMapboxTiles(style_id = "streets-v11",
username = "mapbox") %>%
addPolygons()
Read through the following articles to see what you can do with the package:
- Mapping with mapboxapi
- Using navigation services with mapboxapi
- Creating and uploading Mapbox vector tilesets
- Geocoding with Mapbox and mapboxapi
- Dynamic web maps with Mapbox Tiling Service and mapgl
If you find this project useful, consider supporting package development via PayPal, hiring me to give a workshop on mapboxapi or hiring me to consult on your project. Send me a note at kyle@walker-data.com if this interests you! You can also get updates on package development by signing up for my newsletter:
Please note: Use of Mapbox services through mapboxapi is governed by Mapbox’s Terms of Service and any account restrictions.