Trip planning with AI

Princen Alice
2 min readMar 6, 2021

Planning the type of solo trips that I do is hard work. I already have thousands of places I want to visit in my private uMaps, and people are adding to my public list. When I decide on an area to visit, I already have plenty of places to visit in that area. Breaking that down into manageable daily trips is hard.

So why not use AI to do the hard work for me?

Photo by Andrew Neel on Unsplash

A naive approach to this problem is K-Means Clustering. Given a list of GPS coordinates, cluster them into a predefined number of clusters of locations.

This doesn’t take into account things like which places are all on the same train line, or which places look close together but actually have an uncrossable river between them. But it can give us a good starting point.

So I wrote a Google Colab notebook to do just this.

Using scikit learn’s KMeans function, we can easily group the locations into clusters. And since we already know how many days we have for the trip, we don’t even need to bother doing the work to find the optimal number of clusters. The number of clusters is set by the number of days we have spare.

We can then color each of these points with a qualitative colorscheme and use matplotlib to plot a quick graph to check they look sensible.

Google Colab support for Leaflet is somewhat limited, so instead of plotting the resulting graph we export the generated GeoJSON with uMap’s properties for color.

Underlying map ©OpenStreetMap contributors

If you’ve got your own GeoJSON file then feel free to copy the notebook and try it for yourself — https://colab.research.google.com/drive/1viJn0OK-EZUHeuatFndjw-Kv0Ma5empW?usp=sharing

--

--

Princen Alice

Train/plane rider, big data person, enby. Don't prove we're human unless we really have to. The garbage will do.