Skip to content

is there package can caculate shortest path with shp file in R?

1 message · Roger Bivand

#
On Tue, 20 Mar 2007, StinJia wrote:

            
Not directly. How you develop this will depend on your shapefile. If you 
can get to a matrix of "distances", you can use allShortestPaths() and 
extractPath() in the e1071 package, see:

RSiteSearch("shortest path")

These use full matrices rather than sparse matrices, so for real-scale 
problems, it may not be all you need, but it is a start.

If the shapefile is a network, you'll need to find out how to get two 
pieces of information from it: which two nodes it links, and the 
"distance" it represents - these are two different kinds of information, 
and may take some work. There is a graph package in Bioconductor, but I'm 
not sure that it will help. There also seem to be functions in the sna 
package. However, none of them are directly relevant to arcs and nodes 
from shapefiles.

Roger