Digital Geography

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 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 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 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.

39
Leave a Reply

avatar
13 Comment threads
26 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
15 Comment authors
SimonPhilippRiccardoShen Ken PingStefan Frerichs Recent comment authors

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

  Subscribe  
newest oldest most voted
Notify of
Florent
Guest
Florent

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

Enrico
Guest
Enrico

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
Guest
Florent

Thanks a lot

Rodrigo Principe
Guest

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
Guest

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

Rodrigo Principe
Guest

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
Guest
F. Shah

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
Guest

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

Jani Kinnunen
Guest
Jani Kinnunen

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
Guest

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
Guest

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

Rodrigo Principe
Guest

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
Guest

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

Rodrigo Principe
Guest

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

Mohammed
Guest
Mohammed

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

MikLet
Guest
MikLet

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
Guest

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

MikLet
Guest
MikLet

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
Guest
Many05

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
Guest

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
Guest
Many05

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
Guest
Niel de Jong

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
Guest

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
Guest
Stefan Frerichs

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
Guest
Shen Ken Ping

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
Guest

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

Shen Ken Ping
Guest
Shen Ken Ping

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

Riccardo
Guest

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
Guest
Philipp

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
Guest
Philipp

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

Riccardo
Guest

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

Simon
Guest
Simon

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
Guest

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
Guest
Simon

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.
best,
Simon

Riccardo
Guest

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
Guest
Simon

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
Guest

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
Guest
Simon

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