Closed justinperline closed 9 months ago
Use mapboxapi package mbmatrix() function calculate travel time matrix
Mapbox API limits to 100,000 free calls per month. Instead of brute forcing the matrix between ~32k places and ~200 airports, I'll need to limit the comparisons to only reasonable requests
Had to resort to looping in this case. Identified the closest three airports to each place (3 chosen since this will result in just under 100k comparisons) and only ran the matrix function on those comparisons. Definitely takes longer since each one is a separate API call with needed sleep time in between. Working in batches to complete whole dataset.
Withholding Alaska airports, travel time distribution seems fairly intuitive
On the whole, travel times make sense but at the individual level I'm finding some annoying discrepancies between approximate distance "as the crow flies" and estimated travel time. The correlation is mild but not as strong as I'd expect. In the interest of time, I'll prioritize straight-line distance in this first iteration and can look further into estimating routing times later.
It's a difficult one to debug since it takes place under the Mapbox API hood. I only can see the initial coordinate pairs (which might snap to a nearby road) but not any of the presented routes, to my knowledge.
Spinning the time estimation portion off into #7
Need to calculate travel time to the closest major and mid-major airport from every census-designated place.
This requires:
sf
packagest_read()
function read in ArcGIS URL with airport locationsmapboxapi
packagembmatrix()
function calculate travel time matrix