walkerke / mapboxapi

R interface to Mapbox web services
https://walker-data.com/mapboxapi/
Other
110 stars 8 forks source link

Error `mb_matrix` gives `object 'origin_end' not found` #55

Closed manhnguyen48 closed 1 month ago

manhnguyen48 commented 2 months ago

Hi, first of all thank you for the package that allows convenient access to the Mapbox API via R!

I'm trying to use the API to create travel distance matrix between some points of interest as below but running into issue where it says object 'origin_end' not found. Looks like an issue within the source code. It only happens when you give different list of starting and ending coordinates.

library(mapboxapi)
#> Usage of the Mapbox APIs is governed by the Mapbox Terms of Service.
#> Please visit https://www.mapbox.com/legal/tos/ for more information.

API_token <- Sys.getenv("MAPBOX_API")

starting <- list(
  c(-0.0859801, 51.5046092),
  c(-0.1689392, 51.4994834)
)

ending <- list(
  c(-0.1698787, 51.499825),
  c(-0.159169, 51.5012463),
  c(-0.1308497, 51.5104123)
)

# This doesn't work
res <- mapboxapi::mb_matrix(
  origins = starting,
  destinations = ending,
  profile = "driving",
  fallback_speed = "32",
  access_token = API_token
)
#> Error in mapboxapi::mb_matrix(origins = starting, destinations = ending, : object 'origin_end' not found

#This works
res <- mapboxapi::mb_matrix(
  origins = starting, 
  profile = "driving", 
  fallback_speed = "32", 
  access_token = API_token
)

Created on 2024-08-19 with reprex v2.1.0

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.1 (2024-06-14 ucrt) #> os Windows 10 x64 (build 19045) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United Kingdom.utf8 #> ctype English_United Kingdom.utf8 #> tz Europe/London #> date 2024-08-19 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> aws.s3 0.3.21 2020-04-07 [1] CRAN (R 4.4.1) #> aws.signature 0.6.0 2020-06-01 [1] CRAN (R 4.4.1) #> base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.4.0) #> class 7.3-22 2023-05-03 [1] CRAN (R 4.4.1) #> classInt 0.4-10 2023-09-05 [1] CRAN (R 4.4.0) #> cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.1) #> codetools 0.2-20 2024-03-31 [1] CRAN (R 4.4.1) #> crosstalk 1.2.1 2023-11-23 [1] CRAN (R 4.4.0) #> curl 5.2.1 2024-03-01 [1] CRAN (R 4.4.0) #> DBI 1.2.3 2024-06-02 [1] CRAN (R 4.4.1) #> digest 0.6.36 2024-06-23 [1] CRAN (R 4.4.1) #> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.4.0) #> e1071 1.7-14 2023-12-06 [1] CRAN (R 4.4.0) #> evaluate 0.24.0 2024-06-10 [1] CRAN (R 4.4.1) #> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.0) #> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0) #> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.0) #> geojsonsf 2.0.3 2022-05-30 [1] CRAN (R 4.4.1) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.4.0) #> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0) #> htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.4.0) #> httr 1.4.7 2023-08-15 [1] CRAN (R 4.4.0) #> jpeg 0.1-10 2022-11-29 [1] CRAN (R 4.4.0) #> jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.4.0) #> KernSmooth 2.23-24 2024-05-17 [1] CRAN (R 4.4.1) #> knitr 1.47 2024-05-29 [1] CRAN (R 4.4.1) #> lattice 0.22-6 2024-03-20 [1] CRAN (R 4.4.1) #> leaflet 2.2.2 2024-03-26 [1] CRAN (R 4.4.1) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0) #> magick 2.8.4 2024-07-14 [1] CRAN (R 4.4.1) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.0) #> mapboxapi * 0.6 2024-05-10 [1] CRAN (R 4.4.1) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.0) #> png 0.1-8 2022-11-29 [1] CRAN (R 4.4.0) #> protolite 2.3.0 2023-09-25 [1] CRAN (R 4.4.1) #> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.4.0) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.4.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.4.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.4.0) #> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.4.0) #> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.4.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0) #> raster 3.6-26 2023-10-14 [1] CRAN (R 4.4.1) #> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.4.0) #> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.4.0) #> rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.1) #> rmarkdown 2.27 2024-05-17 [1] CRAN (R 4.4.0) #> rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.4.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0) #> sf 1.0-16 2024-03-24 [1] CRAN (R 4.4.1) #> slippymath 0.3.1 2019-06-28 [1] CRAN (R 4.4.1) #> sp 2.1-4 2024-04-30 [1] CRAN (R 4.4.1) #> stringi 1.8.4 2024-05-06 [1] CRAN (R 4.4.0) #> styler 1.10.3 2024-04-07 [1] CRAN (R 4.4.0) #> terra 1.7-78 2024-05-22 [1] CRAN (R 4.4.1) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.4.0) #> tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.4.0) #> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.0) #> units 0.8-5 2023-11-28 [1] CRAN (R 4.4.1) #> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.0) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.0) #> withr 3.0.0 2024-01-16 [1] CRAN (R 4.4.0) #> xfun 0.45 2024-06-16 [1] CRAN (R 4.4.1) #> xml2 1.3.6 2023-12-04 [1] CRAN (R 4.4.0) #> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.4.0) #> #> #> ────────────────────────────────────────────────────────────────────────────── ```