[R-sig-Geo] neighborhood with

Nicholas Lewin-Koh nikko at hailmail.net
Fri Nov 30 02:30:03 CET 2007


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))

> 2nd.ord.neigh<-setdiff.nb(k2,k1)
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.

Hope this helps,
Nicholas

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
> polygons.
> I want to use topology and not a distance criterion.
> 
> I hope to be comprehensible, sorry for my rusty english.
> 
> Alban Thomas
> -- 
> ____________________________
>        Alban Thomas
> http://alban-thomas.exen.fr/




More information about the R-sig-Geo mailing list