This is Fedja. Fedja is a 3-year old, happy, friendly, and fluffy Samoyed, who loves long walks and (because of the not-so-distant history of Samoyeds as sledge dogs) needs a lot of exercise. Fedja is lucky enough to live near to a natural reservation area, and to have an owner who also loves to go outdoors. That is me.
Every day in the afternoon, after a day in the home office (Fedja is a great foot-warmer also!) we go and explore the nature.
After three years of these daily walks I still try to find new routes and places to see, and today, on one of the most enjoyable walks across the spring forest, I started to think how I actually decide where to go. How do we hoomans understand our surroundings, and what are the attractions and no-go zones of a (dog) walk?
Designing routes with Fedja
Our neighborhood is very heterogeneous. If I draw a circle with 2-km radius around our house, it holds three lakes, a river, a small hill with a slalom slope, forests, fields, and quite active residential area with its services (including the hospital where I was born). It is like a Carcassonne table game in real life. Every day I can choose where to go and what kind of things I want to see. Still, it seems that there are some routes that attract me regularly, while others are very rarely explored. Why is that?
Of course, having a dog with me puts some requirements. The route must visit some of the public trash cans because we need to pick up all dog litter. Then there are multiple other, time- and situation-dependent variables:
- The season. Winter months expand our territory, because we can walk on ice-covered lake. In autumn, our routes tend to visit some very secret mushroom spots on the forest. (I have tried to teach Fedja to recognize the smell of trumpet-shaped chanterelle, but with no success.)
- The weather. The weather conditions have less impact than you could assume, because daily walks must be done anyway. We Finns have a saying: “There is no such thing as bad weather, there is only bad equipment”. But if the roads are very slippery, or there is a lot of snow, it is better to stay on bigger roads. In the summertime, rain can change some small paths too muddy for our coat. I bet you understand. Just look at the picture above.
- The hour. It gets dark quite early in the winter. There are no street lamps in the forest. More specific time is around 2 PM on weekdays, when it is not wise to pass the elementary school, at least if we are in a hurry. I mean, can you imagine a single child who does not want to pet this snowball?
I’m sure that I am not the only one who does not want to use the same street twice during one walk. Actually, when I occasionally record my walks with SportsTracker, I have noticed that my routes are surprisingly round. Crossing my own path once is acceptable.
If the length of our walk is limited, and we stay on paths and roads (except short mushroom nips!), there must be a finite number of routes. And, considering my extensive experience of this area, one could assume that I have tried most of them. It would be really interesting to see how some route optimization algorithm would plan a walk for me. AI has been found to be successful in designing for example user interfaces; it suggests quite unconventional solutions that still are acceptable by humans. Could it also find new aspects to our walks? So far, the route optimization algorithms have been focusing on shortest or fastest route between two discrete points. Wandering around and coming back to where you left might still be unthinkable concept for AI.
After sleeping overnight, I realized that the task was not as impossible as it seemed. The same algorithms that optimize travel time can be modified to prefer good walking paths. I just need to read the road class information from the attributes and make the algorithm to use it when calculating “fastest” route. In road type classification, smaller numbers typically mark higher class, i.e. bigger roads, and vice versa. Then I thought that I still need a programmer to do that, but after a while I also understood that it might, just might be possible for me with QGIS and open data! QGIS offers a wide selection of network analysis tools and a graphic processing modeler, and all the data I need is openly available.
With my almost-forgotten knowledge about algorithms, and with very limited experience of QGIS processing modeler, I sketched a model for finding a suggestion for a dog walk.
Creating the model using open datasets & QGIS processing modeller
I used the road network of Geographical Database, which is open data from National Land Survey Finland. Trash cans are actually bus stops (but there is a trash can in every bus stop) from OSM. The model still has many flaws; the weather and time conditions are missing, and it does not really prefer smaller roads but simply picks all nicely walkable roads from the bigger road network. It also doesn’t consider the length of the final route. Still I am quite proud and amazed how I could create this in only couple of hours. It looks very impressive, doesn’t it?
The model finds a random “destination” point. Then it calculates the shortest path to that destination and finds the closest trash can along the way. next, it changes the route so that it goes from home to that trash can and then to the destination. After that, it removes these “used” routes from the network and calculates another route back home. This prevents the same route for another direction. Finally, it combines routes home - trash can - destination and destination - home into a single route.