walkerke / mapboxapi

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

mb_batch_geocode -- Error in `purrr::list_rbind()`: `x` must be a list, not null #56

Closed daranzolin closed 6 days ago

daranzolin commented 6 days ago

Reprex:

library(tibble)
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.

df <- tibble(
  address = "34 alta st",
  city = "San Francisco",
)

mb_batch_geocode(
  df,
  address_line1 = address,
  place = city,
  access_token = Sys.getenv("MAPBOX_PUBLIC_TOKEN")
  )
#> Error in `purrr::list_rbind()`:
#> ! `x` must be a list, not `NULL`.
#> Backtrace:
#>     ▆
#>  1. ├─mapboxapi::mb_batch_geocode(...)
#>  2. │ └─purrr::list_rbind(batch_content$batch$features)
#>  3. │   └─purrr:::check_list_of_data_frames(x)
#>  4. │     └─vctrs::vec_check_list(x, call = error_call)
#>  5. │       └─vctrs::obj_check_list(x, ..., arg = arg, call = call)
#>  6. └─vctrs:::stop_non_list_type(x, y, z)
#>  7.   └─cli::cli_abort(...)
#>  8.     └─rlang::abort(...)

Created on 2024-09-11 with reprex v2.0.2

walkerke commented 6 days ago

mapboxapi doesn't support tidyeval, so you'll need to quote your column names:

library(tibble)
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.

df <- tibble(
  address = "34 alta st",
  city = "San Francisco",
)

mb_batch_geocode(
  df,
  address_line1 = "address",
  place = "city",
  access_token = Sys.getenv("MAPBOX_PUBLIC_TOKEN")
)
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -122.4037 ymin: 37.80174 xmax: -122.4037 ymax: 37.80174
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 6
#>   address    city  matched_address accuracy confidence             geometry
#> * <chr>      <chr> <chr>           <chr>    <chr>               <POINT [°]>
#> 1 34 alta st San … 34 Alta Street… rooftop  medium     (-122.4037 37.80174)

Created on 2024-09-11 with reprex v2.1.0