Hi,

Thanks for your replies. The nblag() function is exatcly what I needed. In
fact I find it by myself. Here's the code I used :

nb2<-nblag(nb,2)
nb_tot<-union.nb(nb2[[1]],nb2[[2]]) # All neighbors in the same nb object
glist <- vector(mode="list", length=length(nb_tot))
for (i in seq(along=nb_tot))
        glist[[i]] <- ifelse(nb_tot[[i]] %in% nb[[i]],1,0.5)
# 1st order neighbors get a weight = 1 ; 0.5 for 2nd order ones
listw<-nb2listw(nb_tot,glist=glist,style="B",zero.policy=TRUE)

Sorry for my haste question and thanks again.

Alban

PS : Nicholas, thanks for the forward. Next time I will use the r-sig-geo
list.

2007/11/30, Roger Bivand <Roger.Bivand@nhh.no>:
>
> 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))
> >
> >> 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.
>
> 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.
>
> Roger
>
> >
> > Hope this helps,
> > Nicholas
> >
> > On Thu, 29 Nov 2007 13:42:05 +0100, "alban thomas"
> > <alban.thomas.fr@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/
> >
>
> --
> Roger Bivand
> 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@nhh.no
>



-- 
____________________________
       Alban Thomas
http://alban-thomas.exen.fr/

	[[alternative HTML version deleted]]


