35

I was wondering if there are any alternatives to pgRouting tools.

Thinking about it for a bit, I think the only alternative is to use R or RPY to do the analysis.

Basically I'm trying to solve routing problems based on nonPostGIS databases. As most of my data is actually stored in a different format; however, it's not to hard to convert. I'm finding that pgRouting to my dumb silly brain is difficult to implement. So perhaps a non-database solution that I can easily tweak would be ideal for me

12 Answers 12

20

[Edit: this has been superseded by nx_spatial which is available from pypi (easy_install nx_spatial). Importing shapefiles is now standard in networkx 1.4]

I've been kind of disappointed by the lack of geometric network tools in ESRI's Python GP API, so I wrote up something that loads Shapefiles and Feature Classes into networkx directional graphs (DiGraphs).

It is still a work in progress, but it might be an okay starting off point for something that can help with your problem.

http://bitbucket.org/gallipoli/utilitynetwork/

Samples:

from utilitynetwork import Network

net = Network()

#load single file, method reqs OGR
net.loadshp("/shapefiles/test.shp")

#load directory full of shapefiles
net.loadshp("/shapefiles")

#load a feature class, req ESRI gp object, should work with shps as well
import arcgisscripting
gp = arcgisscripting.create(9.3)
net.loadfc("C:\somedb.gdb\featureclass", gp)

#Accessing node/edge data is done by the key value (the geometry as a tuple).
#access node data at x=4, y=2
nodekey = (4, 2)
net.node[nodekey]

Network is inherits from networkx.DiGraph, so all of that functionality is available.

11

Although the thread is a bit old, I wanted to add a few links about routing in case someone ends here like I did:

5

There's Flowmap, a niche GIS package designed for dealing with network analysis issues.

If you have a fairly simple use-case, the QGIS-based Quantum Navigator might do the trick.

GRASS also supports network analysis, though it may not be worth the friction of getting things set up inside of the environment.

4

If you're looking for a programatic pythonic solution, take a look at networkx

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • Any libraries for going from .shp to networkx? I could build one myself in Python, but I'd rathe rnot reinvent the wheel... – fmark Jul 30 '10 at 3:16
  • 4
    Its not exactly a 1:1 match since shapefiles store data as simple features, not topological networks. So you need to know/assume some things about your source dataset first - primarily that all intersections are terminal nodes for a linestring. Here is an example of using geodjango to convert simple features into a networkx graph: code.google.com/p/marinemap/source/browse/lingcod/spacing/… – perrygeo Aug 2 '10 at 16:17
3

You can have a look into the open source GraphHopper project - a fast and flexible route planner. Try it out here. Note: I'm the author

  • I am vouching for GraphHopper as it is super simple to setup and use. – bugmenot123 Sep 18 '18 at 15:01
2

You could use GeoTools' graph package to do the routing too.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

2

You can also have a look at the tools from RouteWare. Long track record and not database bound

2
+50

We also did some research the last years but we are still happy with pgRouting and think it is the best solution for our GIS-Routing-needs. Unfortunately there is not much around that I know of (without having to pay thousands of Euros/Dollars). We work with Navtech-Data, that has a perfect network to work with but is not cheap. We also tried from time to time with OSM which worked OK ... but always made some problems and therefore never made it into production.

We also just came across the above mentioned open source GraphHopper project (some weeks ago) and think, that it has very good performance und possibilities. As far as I know - they also have OSM Data running within their project.

1

Not sure if that fits your particular requirements bu it might be worth looking at network extension of gvSIG.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1

Many routing problem use Dijkstra's algorithm to determine shortest path. It's relatively straightforward to code: http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Also, Guido van Rossum wrote an early essay about graphs in Python. His short piece includes an approach for primitive route data structures and coding: http://www.python.org/doc/essays/graphs.html

There are a lot of routing packages out there. For specifically geographic purposes, besides pgRouting, graphserver (http://bmander.github.com/graphserver/) and ESRI ArcGIS Network Analyst come to mind. The social network analysis community has a list of graph analysis software at: http://www.insna.org/software/index.html and http://www.insna.org/software/software_old.html. Many of those packages are open source and relevant in a geographic context. For highly-sophisticated, robust or complex calculations, linear programming packages like CPLEX and Lindo Lingo might be worth investigating.

  • the problem is that most of these solutions need a system of nodes and links, and GIS data is usually not stored that way – dassouki Aug 5 '10 at 11:06
  • 1
    Network analyst is about $2,500 and not really interested in making such a purchase now. I'd rather have a pythonic solution – dassouki Aug 5 '10 at 11:07
  • 2
    Dijjkstra is for very basic graphics. For real life problems, usually it is a very heavy and slow algorithm. Also, ESRI software, as it is not open sourced, is difficult to improve and is slowly being left behind in favor of other tools. – María Arias de Reyna Domínguez Dec 11 '13 at 11:43
  • @dassouki all GIS data is essentially nodes and links, and tools like osm2pgrouting, and other pgRouting scripts in general, convert existing GIS / spatial data into the necessary nodes and links and edges that are used in pgRouting... – DPSSpatial Jan 27 '16 at 21:53
1

In Alpha release but looks promising:

GeoDaNet (Alpha) - Spatial point pattern analysis on networks (based on PySAL Ptyhon library, concieved in GeoDa centre).

(Slides, manual, download.)

1

You can use Grasshopper API - They have a matrices component that you can work within called the Matrix API

There is also Mapzen Leaflet Routing Plugin or the Mapzen Valhalla engine

as well as Mapbox Distance API which you can tap into the

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.