Skip to content

Calculate distance along a path

4 messages · Barry Rowlingson, Jacqueline Schweizer, Javier Garcia-Pintado

#
On Tue, Jan 28, 2014 at 3:14 PM, Rafael W?est <rafael.wueest at gmail.com> wrote:
Looks good.

 You need three data sets - a line data set of the paths, a point data
set of the bus stops, and a point data set of the grids.

 From line data set you build a topological graph with distance as edge weights.

 Snap the bus stop and grid centres to the nearest point on a path.

 Do shortest-distance path search between grid cells and bus stops.

 It would be useful to know how complex your path network is, and how
many grid cells you want to do, and how many bus stops you have. But
in principle all the functions are there in the igraph, sp, and rgeos
packages (and a few others).

 R is a construction kit....

Barry
#
Hi Jaqueline,

Yes, as Barry indicates this can be well done in R. I've done that [using rgeos, sp & igraph] for assimilation of sparse selected satellite info [your busses] into 2d flood models in braided systems [your cells] which follow a predefined skeleton of connectivity (e.g. urban areas of a network of rural channels).
Specifically, you can obtain the nearest point in a path to your cells [this nearest point is not neccesarily an explicit node in an existing polyline, but could faill in a segment between consecutive points]. Then, this nearest  point has a "chainage" [a along-polyline distance from its starting vertex]. You can use that chainage to obtain the shortest along-network distance for points wich are not vertices in the graph, by using the previously igraph-calculated between-vertex shortest distances, and adding the "chainages". Note in this step there is a little more to think about the 4 or 5 possible shortest paths, but surely you'll come across it when you reach this point.

I've done all this in R and works beautifully.

Good luck,

Javier

---
Dr. Javier Garc?a-Pintado
National Centre for Earth Observation (ESSC-NCEO)
Data Assimilation Research Centre
School of Mathematical and Physical Sciences
University of Reading
Tel: +44(0)1183787722
j.garcia-pintado at reading.ac.uk
http://www.nceo.ac.uk/