How far can you travel? Answers in QGIS with OSM route.

My latest posts on routing in QGIS were read from some guys at the University Heidelberg who provide the API for the routing. The contacted me with the simple call: “Let’s create a plugin”. And here it is: OSM route…

OSM route

OSM route is more or less a possibility to interact with the service behind the domain openrouteservice.org. It lets you use addresses as input for your start- and end-point as well as an address to be on the way. This information is send to the API of openrouteservice.org and the response is converted into a polyline. Additionally I am adding the points to the map as a point shapefile. At the moment it only analysis the whole route and does not separate each segment of the route.
Interface OSM route
Interface of OSM route… simple as fcuk
For longer routes it took some time to convert the graph. Here are some measures for different routes (travel mode car, distance type: fastest):
  • 0.224828s Distance: 1045.4578 km from Berlin to Paris
  • 0.148206s Distance: 573.9421 km from Berlin to Warschau
  • 0.21995s Distance: 491.5858 km from Berlin to Würzburg
  • 0.868936s Distance: 4494.0776 km from Berlin to Kairo
  • 1.128764s Distance: 7880.0434 km from Berlin to UlaanBaatar
routes in QGIS
routes between major cities in QGIS

Reachability/Service Times

But that’s not all! Additionally to routing you can use the plugin to calculate the reachability of places in a given time period. So called isochrones. Actually the plugin does not create lines but polygons. You can choose a time (maximum 30min as stated by the API provider) and a time for given intervals. So choosing 10 as time and 2 as intervals will provide 5 polygons for each min-interval (2min, 4min, 6min, …). This will give you the great opportunities to compare different locations in their “centrality” or to choose your next flat wisely if you have the latest point shapefile of club-locations or book stores in your desired area. It works on the input address only!
Berlin in 30min
Berlin with its accessibility by car in 30min divided in 5min intervals
You can participate with any errors/issues via Github. It is available using the official plugin page of QGIS and via the “Manage and Install Plugins” dialog in QGIS. The plugin is marked as experimental ATM.

ATTENTION: The OpenRouteService.org API does allow routing only on the continents Europe, Asia, Africa and Australia. We are in contact regarding this issue.

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

39 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Florent
Florent
8 years ago

Nice post! But i cant find where to download this Plugin ?

Enrico
Enrico
8 years ago
Reply to  Florent

1.The download link is here: https://plugins.qgis.org/plugins/OSMroute/
2. Otherwise within QGIS plugin manager enable “experimental plugins” under settings and then search for “OSM route” and install as usually

Florent
Florent
8 years ago
Reply to  Enrico

Thanks a lot

Rodrigo Principe
8 years ago

awesome.. keep it going! I think it will help me a lot.. by the way, do you know any plugin to search features values within the “view”.. I have made one for Arcview 3.x that suited my needs, but I can´t get it around with pyqgis (can´t find a GOOD basic programming tutorial). I use the MMQGIG plugin, which is similar to the one I made, but is still missing some things..

Riccardo
8 years ago

You are searching for OSM data in the view or for every layer features in your current view?

Rodrigo Principe
8 years ago
Reply to  Riccardo

every layer features.. I work in urban forestry and
have made a system in arcview 3.x to manage the 16K features (trees). It is used by people with few computer skills, so I had to make it easy-to-use.. now I am trying to migrate to QGIS but I couldn’t find time to learn python to custom my system..

blow the dust of arcview 3.x and have a look at my ext.. https://www.dropbox.com/s/92zk25dds9o6ghg/busqueda1-3.avx?dl=0

I hope some day somebody make a good videotutorial to learn pyQgis from the beginning.. well, thanks to answer Riccardo, I love your work, keep it going!

F. Shah
F. Shah
8 years ago

Good work.. Last year there was a very good blog post by Paul Blazer’s on “ÖPNV Fahrzeit Heatmap”, you might want to have a look on it.

http://mechlab-engineering.de/2014/05/tutorial-entstehung-der-oepnv-fahrzeit-heatmaps-2-0-mit-postgresapp-tilemill-und-qgis/

Riccardo
8 years ago
Reply to  F. Shah

saw it. I hope openrouteservice.org will integrate this sort of routing in the near future!

Jani Kinnunen
Jani Kinnunen
8 years ago

Nice! Any idea which plugin to use in QGIS to to find shortest and fastest route with multiple stops between start and end point?

Riccardo
8 years ago
Reply to  Jani Kinnunen

We can enhance the plugin for you 😉 it’s all about the money… and please make up an issue on github. maybe we will include the functionality for free…

Rodrigo Principe
8 years ago
Reply to  Jani Kinnunen

I join the request. I will visit github.. could I fork it?

Rodrigo Principe
8 years ago

Hey Riccardo, the button that says “map it” is for selecting the start address directly from the map? isn’t available.I couldn’t make the plugin work for 2 cities in argentina, a python error comes out..

Riccardo
8 years ago

Argentina is not supported from openrouteservice.org. the map it buttons will be enabled in a fture release of the plugin.

Rodrigo Principe
8 years ago
Reply to  Riccardo

Thanks. I’ll keep using GeoSearch plugin for now.. Isn’t bad anyway.

Mohammed
Mohammed
8 years ago

Hi Riccardo, I always have a python error even when I enter same parameters in the example provided above?

MikLet
MikLet
8 years ago

Hi Riccardo,
I would like to know the parameters designed in pedestrian and car ? i.e. how much km/h miles/h ?

I’m trying to go further usefullness of your plug-in. I just want to understand, and try to understand strenght and weakness of such usefull plug-in.

I identify one issue about OSM quality. but others ?

Topography is taken into account ?

Riccardo
8 years ago
Reply to  MikLet

get some more information on the OSM wiki page here: http://wiki.openstreetmap.org/wiki/OpenRouteService#Used_OSM_Tags_for_Routing

MikLet
MikLet
8 years ago
Reply to  Riccardo

Thanks !!! Look there : https://sites.google.com/site/meltworks/home, it may be a good vision from what i expected to do with OSMroute and thus your plugin.

Many05
Many05
8 years ago

Great work and very usefull
! Is it possible to add multiple addresses from a file?

Or for now we can not go a single address by hand ?
Thank you for your response

Riccardo
8 years ago
Reply to  Many05

You can always make up an issue or the whish of enhancement on the github page of the plugin. Yet we have to face it: multiple addresses willcreate multiple calls/requests and the API only accepts 1000 per hour which makes 31 addresses.
Maybe there will be someone who will work on this issue in his/her sparetime. If you need it asap, just send us a line to info@geolicious.de and we will write an offer for your requirements.
The second: what do you mean by “Or for now we can not go a single address by hand ?”

Many05
Many05
8 years ago
Reply to  Riccardo

Thanks for your return.
I have my answer.

By “Or for now we can not go a single address by hand ?”, I mean informing an address manually, but it’s ok for me.

Thanks again,

Niel de Jong
Niel de Jong
7 years ago

Hi Riccardo,

Great plugin tnx! I’m computing a set of isochrones at the moment, 5 minutes max with intervals of one minute by foot. Sometimes it leaves out the first minute or couple of minutes, any idea why it would do that?

Riccardo
7 years ago
Reply to  Niel de Jong

Hi Niel. I think this is a problem of the travelling distance: I mean sometime you cant walk to the next OSM node in 1 min… Can you test it on openroutservice.org whether this works there?

Stefan Frerichs
Stefan Frerichs
7 years ago

Hi Riccardo,
Thanks for the plugin. Unfortunately, it produces in QGis 2.16 nonsensical coordinates when I try to calculate the isochrones with respect to a motorway (30 min, 2 minute interval). As a starting point I use a coordinate from the website (51. 882 8. 4311), which I copy to the plugin. The website produced the desired result, unfortunately I can not use it. What could be wrong?

Shen Ken Ping
Shen Ken Ping
7 years ago

Hi Riccardo,
First I want to thanks for this useful plugin.
Just have a problem is I do remember that I could put coordinate in “Start address”, but now it’s always shows me that :
Python error: An error has occurred while executing Python code: See message log (Python Error) for more details.
I do know that I can put address but for a big park or construction I need a precise point, is that possible to put coordinate?

Riccardo
7 years ago
Reply to  Shen Ken Ping

it worked in my case just lng lat. no separator, decimals separated by poin.
can you give me the coordinates?

Shen Ken Ping
Shen Ken Ping
7 years ago
Reply to  Riccardo

yes of course
it’s 49.42704,7.75837,should be in Pfaffenbergstraße 97, 67663 Kaiserslautern

Riccardo
7 years ago
Reply to  Shen Ken Ping

The plugin works with a geocoding of the input field. I could enhance the functionality to use a checkbox so user can also input coordinates directly instead of an address.

Philipp
Philipp
7 years ago

Hi Riccardo,
This plugin is really great but I have a small issue.
If I open an saved map with a isochrone the layer isn’t visible. Do I have to save the isochrome layer individual?

Philipp
Philipp
7 years ago
Reply to  Philipp

Hi
I just fixed the problem on my own.
Thanks for this awesome tool!

Riccardo
7 years ago
Reply to  Philipp

All files need to be saved seperately when needed for further analysis. check here: https://github.com/Geolicious/OSMroute

Simon
Simon
6 years ago

Hei Ricardo,
thanks for you great work!
I want to run your plugin with pyQGIS, however I do not understand how to add my custom start/endpoint. I struggle to modify OSMrouteDialog(). Is there a way to a) access it with pyQGIS or b) use your python code and feed with my data?
thanks for your help

Riccardo
6 years ago
Reply to  Simon

Hi Simon,

the plugin itself is written in pyQGIS. You can use parts of the source code or embed your own lines in the downloaded version. you can acces the plugin in your qgis2 directory und python/plugins.
What struggle do you see with your “custom start/endpoint”? Maybe ask this on gis.stackexchange as there are for more experts available compared to this thread here.
You can also ping me directly: riccardo.klinger@geolicious.de
I hope this helps.

Best regards,

Riccardo

Simon
Simon
6 years ago
Reply to  Riccardo

Hi Ricardo, thanks for your quick answer. I am new to pyQGIS and python and I wanted to run your plugin using the python console in QGIS. However I failed to do so. I was trying to run OSMroute.py and then customize it to bypass the dialog and add a startpoint manually. For instance I get: ImportError: No module named resources_rc But I did stored this file right in the same folder as OSMroute or is it a special/global package I need to install? Thanks for your help, I couldnt find “my case” in gis.stackexchange, but i seems very helpful.… Read more »

Riccardo
6 years ago
Reply to  Simon

Hi SImon, the core of it are the lines 316-391 of OSMroute.py. Replace all the variables with desired values and you should be able to work with that in the commandline. But be aware of the needed modules: from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication from PyQt4.QtGui import QAction, QIcon, QColor from PyQt4 import QtCore, QtGui from qgis.core import * #to get access to qgis #we will need these for getting the ors response and to parse it: from xml.etree import ElementTree import urllib2, os, qgis.utils, os.path, resources_rc, time #we need qvariant to build the shapefile from PyQt4.QtCore import QVariant… Read more »

Simon
Simon
6 years ago
Reply to  Riccardo

Hi Riccardo, it seems that I got the problem solved about the imports. However everthing else seems to be much more complicated than I anticipated 🙂 Maybe I need to look more into python itself. Even if I customize the input in the metioned lines, I am not able to run the “run” function in OSMroute.py as it is called within “__init__” which is called in OSMroute_dialog.py which I obviously dont need/use as I want to skip the gui and add the input in the python console. Or should I run OSMroute_dialog.py as a main methode? Sorry to bother you… Read more »

Riccardo
6 years ago
Reply to  Simon

Hi Simon, don’t use the files at all! I suggested just to use the code lines. but for this: here is the minimal example: from xml.etree import ElementTree import urllib2, os, qgis.utils, os.path, resources_rc, time #we need qvariant to build the shapefile from PyQt4.QtCore import QVariant import processing from qgis.core import * #to get access to qgis from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication from PyQt4.QtGui import QAction, QIcon, QColor from PyQt4 import QtCore, QtGui import time url=”http://openls.geog.uni-heidelberg.de/routing?api_key=e2017639f5e987e6dc1f5f69a66d049c” text = ”’ Car Fastest 12.2429261 51.8311104 13.4385964 52.5198535 ”’ req = urllib2.Request(url=url, data=text, headers={‘Content-Type’: ‘application/xml’}) response_route=urllib2.urlopen(req).read() newstr = response_route.replace(“n”, “”) response_route… Read more »

Simon
Simon
6 years ago
Reply to  Riccardo

Hei Riccardo,
It is working!! Thank you so much for your time, patience and code 😉
cheers