[R-sig-Geo] Calculate distance along a path

Javier Garcia-Pintado j.garcia-pintado at reading.ac.uk
Tue Jan 28 18:31:57 CET 2014


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).

>From my experience the only I can add on top of what has been said is that building a graph including all points in the polylines you may have, may result in a daunting graph. I believe it will result in a much faster calculation to assume that each polyline is an edge bounded by two vertices [junctions between polylines], and embed the length of the polyline into the properties of the associated graph to obtain the shortest path between vertices as a preprocessing step. If, e.g. we say a node is any point in a polyline, and a vertex is just the starting or ending point of that polyline, then we would be further interested in getting between-node distances.

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/


________________________________________
From: r-sig-geo-bounces at r-project.org [r-sig-geo-bounces at r-project.org] on behalf of Barry Rowlingson [b.rowlingson at lancaster.ac.uk]
Sent: 28 January 2014 16:23
To: Rafael Wüest
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] Calculate distance along a path

On Tue, Jan 28, 2014 at 3:14 PM, Rafael Wüest <rafael.wueest at gmail.com> wrote:
> http://rpubs.com/geospacedman/routing
>
> could be a start...
>
> Hope this helps,

 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

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list