Hello,
Can Alteryx calculate the public transit distance between two places? I do have the geospatial package within Alteryx.
If not is there any alternatives? besides this one: https://community.alteryx.com/t5/Alteryx-Designer-Discussions/HERE-Developer-Transit-API-Pull-with-A...
( I looked into HERE API, found my APP ID /CODE doesn't work or the API call does not return results)
Thanks,
-KW
Solved! Go to Solution.
Hi @BosKev
This is doable through Alteryx, but as you allude to in your post, you'll need to connect to an API. There are many APIs available that do this; I use the Goolge Maps API to bring public transport information into my workflows (but there are many APIs available that help you do it. For example, in a workflow I have open now I can see:
Note that:
- i can see transport time by transit (far right of table) and the travel times (minutes); I can also choose walk, cycle and drive if preferred
- the tool I have doing this is a custom macro (circled above) that returns the distance between two places I'm considering
The custom macro needs lots of upstream data from the workflow (as there's other things going on in it), so won't send here - for this reason and the fact it contains a lot of my credentials. But to talk you through the process in its simplest form:
- generate the URL either by inserting into a text input, or using a formula tool to dynamically generate the URLs you want
- for Google Maps, one way this key would need to look (there are other methods, even within google maps API) would be:
- From here, as you've requested JSON, you can use the JSON parse tool to transpose the information you want
- This method uses the directions API, but you can also use their distance matrix API, which URL would look like:
https://maps.googleapis.com/maps/api/distancematrix/json?origins=Boston,MA|Charlestown,MA&destinations=Lexington,MA|Concord,MA&departure_time=now&key=YOUR_API_KEY
Note that you'll need to generate a Google Maps key in order to do this; there's also many other ways to get this information from Google's API - all the info on this and how to generate keys is available in the documentation here:
https://developers.google.com/maps/documentation/directions/start
https://developers.google.com/maps/documentation/distance-matrix/intro
Finally, if you want to see a video of connecting to the Google Maps API in Alteryx, there's a free webinar I did on this available here:
https://pages.alteryx.com/Connecting-and-Using-APIs-OW.html
Hope some of the info here is of help to you!
Andy
Hi, @andyuttley, appreciate the write up.
I didn't think Google direction api. can provide transit info. I'll look into it much appreciated. (We did build a Google distance matrix api flow but it only works sometimes)
Also, you mentioned macro you created to handle the call? how does it work? Usually I use a formula tool with the api call address and parameters coming from input file for batch processing. (i.e. multiple to-from addresses)
Thanks,
BosKev
Hi @BosKev
Glad it helped. Yes, that's exactly what my macro does too - it has a formula that is generating each of the URLs (updating the TO and FROM Ids) and doing all the parsing of the results. I've found it to be pretty robust, but likely because I'm using Goolge's place_ids (as opposed to free text searches - which it can also handle in theory), which may explain why it is more reliable I guess.
Thanks
Andy