On 23/06/19 2:38 PM, Rolando Valdez wrote:
I am sorry, I was not clear enough. My goal is to calculate a spatial
weight matrix (nxn) across counties but, instead of euclidean distance,
to use road distance.
I'm afraid I still don't understand. To put it mildly. You presumably
have a clear idea of what you are trying to, but those of us who are not
involved in your research have no such idea. We (or at least I) haven't
a clue as to what you are talking about.
What do you mean by "spatial weight"? What are these weights used for?
What is n? How are the counties involved? Is n the number of counties?
Are you interested in the road distance (minimum road distance?) between
pairs of counties?
Please explain *clearly* and do not expect those who are trying to help
you to be mind-readers!!!
cheers,
Rolf
El s?b., 22 de jun. de 2019 a la(s) 19:28, Rolf Turner
(r.turner at auckland.ac.nz <mailto:r.turner at auckland.ac.nz>) escribi?:
On 23/06/19 1:17 PM, Rolando Valdez wrote:
> Thank you for your answer.
>
> I have a shapefile with, say, counties, and I got another
> the roads. ?What if a county does not intersect any road?
I am sorry, but it is not at all clear to me just what the problem
How do the counties come into the picture? You said you wanted to
the road distance between points on the roads. What have the
got to do with this?
Can you perhaps provide a reproducible example?
cheers,
Rolf
>
> El jue., 20 de jun. de 2019 a la(s) 19:08, Rolf Turner
> (r.turner at auckland.ac.nz <mailto:r.turner at auckland.ac.nz>
<mailto:r.turner at auckland.ac.nz <mailto:r.turner at auckland.ac.nz>>)
escribi?:
>
>
> On 21/06/19 12:26 PM, Rolando Valdez wrote:
>
> > Dear community,
> >
> > Is there any way to create a spatial weight matrix based
> > I am trying to use the road distance between two points
> > euclidean distance.
> >
> > I've seen that there is a package named osrm. Can anyone
> some advice?
>
> I don't know anything about "osrm". Calculating "road
> can be
> done in the spatstat package reasonably easily, if you take
> to represent your collection of roads as a "linnet" object.
>
> Given that you have done so, suppose that your linnet object
> that you have vectors "x" and "y" specifying the points on L
> 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]
> distance between point i and point j. (Of course the
> are all 0.)
>
> If your collection of roads is specified by means of a
> vignette("shapefiles") will tell you how to turn this
> "psp" ("planar segment pattern") object; the function (method)
> as.linnet.psp() can then be used to turn the "psp" object
> "linnet" object.
>
> HTH