GSoC 2012 Neo4j and OSM Routing
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore Update and rename README.asciidoc to Feb 23, 2015

Neo4j/OSM Routing Project

"Implementing route analysis of OpenStreetMap (OSM) data within uDig, using the Neo4j-Spatial graph database"

This project began during Google Summer of Code 2012, by Carol Hansen and mentored by Davide Savazzi. The project was supported by both Neo4j and User-friendly Desktop Internet GIS (uDig) communities. It is intended to be expanded as a uDig plugin, allowing uDig users to plot shortest-path routes using OpenStreetMap data.

More about OpenStreetMap (OSM): OpenStreetMap is a free worldwide map, created by people like you.

More about Neo4j: Neo4j Spatial is a library facilitating the import, storage and querying of spatial data in the Neo4j open source graph database

More about uDig: uDig is an open source GIS desktop application framework.

Included Features

OSM Routing Importer: The OSM Importer is used to parse OpenStreetMap XML files to extract relevant nodes for routing.

Orthodromic Distance


The Importer is not complete. However, in its current state, it includes the following features:

  • One-way and Bidirectional streets

  • Miles and Kilometers: Can import OSM data using both miles or kilometers. Tested using OSM files for both US (Delaware) and Europe (Liechtenstein)

  • ATTENTION (Bug Info): Development was started on creating SHORTCUT relationships between crossroads to optimize routing. However, this is still in progress.

How to Test

I have created a routing test class that you can run in Eclipse. You will need an OpenStreetMap XML file, also the node ID for a Start and End node.

I used the following nodes for my tests...



Dependencies used in project's pom.xml



StringUtils: used for obtaining speed limit in miles from the XML file




Note: neo4j-spatial has a mandatory dependency on GremlinGroovyPipeline from the com.tinkerpop.gremlin.groovy package. The dependency in neo4j is type 'provided', so when using neo4j-spatial in your own Java project, make sure to add the following dependency to your pom.xml, too.

        <!-- Sail support not needed -->
        <!-- Maven support in groovy not needed -->
        <!-- "readline" not needed - we only expose gremlin through 

webadmin -->

If the dependency is omitted, neo4j-spatial will probably throw an exception like this:


at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(

at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.query