Skip to content

shortest path

1 message · Barry Rowlingson

#
On Fri, Aug 31, 2012 at 9:39 AM, Mathieu Rajerison
<mathieu.rajerison at gmail.com> wrote:
For complex geometry you'd probably want to feed this to one of the
GRASS modules that builds topologies. I have a hacky method which I'll
outline...

 * read lines using readOGR
 * use package rgeos to intersect the lines with themselves
 * that gives you a single object containing line segments that are
only two points.
 * create a label for each point based on the x and y coordinate,
suitably rounded
 * that gives you a node label for each point. hence the graph.

I think this will work for data that is relatively clean. It won't fix
certain data errors, for example if a point from one line is very
close to the middle of another line, since no intersection will be
found. Other topology build solutions might notice that point X is
1e-10 from the line from A to B and create an extra node there, thus
'snapping' X to that location and causing a new node in the graph...

 If I didn't have to be on a train in three hours I'd code this up...

Barry