mb_matrix function not working
Luis-2030 opened this issue · 2 comments
Hello
I am working with Ch. 7 in your book and I wanted to run the distance and proximity analysis you have in chapter 7.4. Specifically travel time.
I am bringing and csv file (destinations) and US Census block groups (centroids). When I run the mb_matrix function I get the following error:
Attached is the csv file for destinations.
I wonder if in the problem is in the geocoding process.
FamilyChildCareAndCentersAndPreschools.csv
I used tidygeocoder to geocode the destinations
childcare <- read.csv("D:/Googledrive/COE/FamilyChildCareAndCentersAndPreschools.csv")
childcare$fulladdr <- paste(as.character(childcare$Street),
as.character(childcare$City),
as.character(childcare$State),
as.character(childcare$Zipcode))
geoCodechildcare <- geocode(childcare, address = 'fulladdr',
lat = latitude, long = longitude, method = "arcgis")
childcareSF <- st_as_sf(geoCodechildcare,
coords = c("longitude", "latitude"), na.fail = TRUE,
crs = 4326)
childcareSF <- st_transform(childcareSF, crs = 6501)
stearns_distances <- block_groups("MN", "Stearns", cb = TRUE)
st_crs(stearns_distances)
CRS.new <- st_crs("EPSG:6501")
stearns_6501 <- st_transform(stearns_distances, CRS.new)
library(mapboxapi)
# mb_access_token("pk............, install = TRUE)
# readRenviron("~/.Renviron")
times <- mb_matrix(stearns_6501, childcareSF)`
You are running into this error, which is an open issue in the mapboxapi repo: walkerke/mapboxapi#34. mapboxapi doesn't support many-to-many matrices of that size at the moment, so you'd need to split your childcare facilities into smaller chunks and iterate over the chunks. I have longer-term plans to fix this in the package.
Thank you for the explanation!