[postgis-users] Calculate driving distance in postgis

Craig Miller craig.miller at spatialminds.com
Thu Feb 2 14:35:22 PST 2006


Pre-calculate the distance between any two nodes and dump them in a table.
Then all you have to is to look them up with a SQL join using the IDs of
your nodes.  It won't have to calculate the distance between each of the
vertices on the road segment that goes between two nodes.

--Craig
 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of K Kuo
Sent: Thursday, February 02, 2006 1:09 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Calculate driving distance in postgis

Hi List,
First of all, thanks Arnaud for the reply.
I think pgdijkstra will find the shortest path between two points. However,
I intend to calculate the driving distance which is defined by myself. Any
suggestion? Thanks in advance.

Kurt

Hi List,
Does anyone have a better way to calculate driving distance in postgis?
I have a database which convert from tiger/line data. I have found that I
can use distance_spheroid function to calculate distance between two points,
which supposes to be the shortest distance instead of driving distance, am I
correct? What I am thinking about is that I have to query out all nodes
alone the route, calculate distances for each segment then add them up. I
don't think this is a good approach. Any suggestion?
By the way, the tiger/line data contain fnode, tnode number for each line
segment. How can I get the long/lati value from postgis.

Thank you very much.

Regards,

Kurt




------------------------------

Message: 16
Date: Thu, 02 Feb 2006 09:58:39 +0100
From: Arnaud Lesauvage <thewild at freesurf.fr>
Subject: Re: [postgis-users] Calculate driving distance in postgis
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Message-ID: <43E1C9BF.8050207 at freesurf.fr>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

K Kuo a écrit :
>I have a database which convert from tiger/line data. I have found that 
>I can use distance_spheroid function to calculate distance between two 
>points, which supposes to be the shortest distance instead of driving 
>distance, am I correct? What I am thinking about is that I have to 
>query out all nodes alone the route, calculate distances for each 
>segment then add them up. I don't think this is a good approach. Any
suggestion?

Hi !

I have successfully installed and used pgdijkstra, which is a PostgreSQL
implementation of the Dijkstra algorithm (widely used for shortest path
calculations).
http://www.cartoweb.org/contribs.html
It is very easy to install and fairly easy to use.
This module includes special PostGIS functions that can return the shortest
path between two nodes as a PostGIS geometry (a LINESTRING, I believe).
You would just need to get the Length() of this geometry to have the exact
driving distance between the nodes.

Regards
--
Arnaud


_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list