Skip to content
Prev 27391 / 29559 Next

[FORGED] Create a Spatial Weight Matrix based on road distance

On 21/06/19 12:26 PM, Rolando Valdez wrote:

            
I don't know anything about "osrm".  Calculating "road distances" can be 
done in the spatstat package reasonably easily, if you take the trouble 
to represent your collection of roads as a "linnet" object.

Given that you have done so, suppose that your linnet object is "L" and 
that you have vectors "x" and "y" specifying the points on L (i.e. on 
your roads) between which you want to know the distances.

Do:

     X    <- lpp(data.frame(x=x,y=y),L)
     dMat <- pairdist(X)

The object "dMat" is a (symmetric) square matrix; dMat[i,j] is the 
distance between point i and point j.  (Of course the diagonal entries 
are all 0.)

If your collection of roads is specified by means of a shapefile, 
vignette("shapefiles") will tell you how to turn this collection into a 
"psp" ("planar segment pattern") object; the function (method) 
as.linnet.psp() can then be used to turn the "psp" object into a 
"linnet" object.

HTH

cheers,

Rolf Turner

Thread (24 messages)

Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 20 Rolf Turner Create a Spatial Weight Matrix based on road distance Jun 20 Adrian Baddeley Create a Spatial Weight Matrix based on road distance Jun 20 Andres Diaz Loaiza Create a Spatial Weight Matrix based on road distance Jun 21 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 22 Rolf Turner Create a Spatial Weight Matrix based on road distance Jun 22 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 22 Rolf Turner Create a Spatial Weight Matrix based on road distance Jun 22 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 22 Rolf Turner Create a Spatial Weight Matrix based on road distance Jun 22 Juan Pablo Carranza Create a Spatial Weight Matrix based on road distance Jun 22 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 22 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 22 Juan Pablo Carranza Create a Spatial Weight Matrix based on road distance Jun 22 Rolf Turner Create a Spatial Weight Matrix based on road distance Jun 23 Roger Bivand Create a Spatial Weight Matrix based on road distance Jun 23 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 23 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 23 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 23 Roger Bivand Create a Spatial Weight Matrix based on road distance Jun 24 Andres Diaz Loaiza Create a Spatial Weight Matrix based on road distance Jun 24 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 26 Danlin Yu Create a Spatial Weight Matrix based on road distance Jun 27 Rolando Valdez Create a Spatial Weight Matrix based on road distance Jun 27