[R-sig-Geo] neighborhood with
Roger.Bivand at nhh.no
Fri Nov 30 08:20:48 CET 2007
On Thu, 29 Nov 2007, Nicholas Lewin-Koh wrote:
> Hi Alban,
> I hope you don't mind that I have cc'd the list in my reply, there may
> be more help from out there. I don't think these functions will quite
> get you there. These functions assume that you already have nb.obj
> created and are wanting to preform set operations on the neighbors.
> Ideally you would want to look at knearneigh, and do something like
>> k1<-knn2nb(knearneigh(x, k=1))
>> k2<-knn2nb(knearneigh(x, k=2))
> However these functions are for points not polygons. If your polygons
> are well behaved, ie nicely convex than using the centroids of the
> polygons this would give you a good approximation. poly2nb will give you
> first order neighbors for polygons, but you would have to do a lot of
> work to get the second order ones. Also I am thinking that unless you
> have a very well behaved set of polygons, defining second order
> neighbors could be a topological nightmare. There may be some better
> approaches using GRASS or postgis.
The nblag() function in spdep returns a list of order lags, from first to
maxlag, so the first member of the list is the first order neighbour
object and so on. This looks like what you need from your description.
> Hope this helps,
> On Thu, 29 Nov 2007 13:42:05 +0100, "alban thomas"
> <alban.thomas.fr at gmail.com> said:
>> Good morning Mr Lewin-Koh,
>> I'm trying to use your functions on neighbors list objects (in spdep
>> package). Do you have a more detailed description or references about
>> setdiff.nb(nb.obj1,nb.obj2) and complement.nb (nb.obj) functions ?
>> My objective is to get first and 2nd order neighborhood of spatial
>> I want to use topology and not a distance criterion.
>> I hope to be comprehensible, sorry for my rusty english.
>> Alban Thomas
>> Alban Thomas
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