[R-sig-Geo] How to neighbours list functions match coords?
Roger.Bivand at nhh.no
Tue Nov 9 20:12:36 CET 2010
On Tue, 9 Nov 2010, Lee Hachadoorian wrote:
> The example from the documentation for nbdists() uses two predefined
> objects (columbus and col.gal.nb), so it's not clear to me how
> coordinates are being matched (see below)
> coords <- coordinates(columbus)
> dlist <- nbdists(col.gal.nb, coords)
> Does nbdists() match coordinates via location or row name? Or does it
> rely on the ordering of the objects? What I would like to do is go from
> a SpatialPolygonsDataFrame to neighbourslist to nbdist as follows:
> nb = poly2nb(columbus, row.names = columbus$COLUMBUS_I, queen = FALSE)
> nbdist = nbdists(nb, coords = coordinates(columbus), longlat = TRUE)
> Is this reliable?
Good question. None of these functions check by matching, they assume that
the order is correct, and it is the user's responsibility to make sure
that it is. I'll try to revise the help pages to make this clearer.
Do you think that the functions should check? If so, how, given that by
default matrices do not have row names?
> This question would apply similarly to any neighbours list function with
> a coords parameter, e.g. plot.nb or nb2lines.
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo