Hello Roger,

Thank you a lot for the answer.

The goal was just creating a map using R and Processing to represent
relationships as a neuronal network. (just having fun :))
http://www.flickr.com/photos/10519370@N04/6921277544/

Mathieu


2012/4/11 Roger Bivand <Roger.Bivand@nhh.no>

> On Wed, 11 Apr 2012, Mathieu Rajerison wrote:
>
>  Hi,
>>
>>
>> I'm using spdep to generate neighbors, than listw2lines to create a
>> SpatialLinesDataFrame.
>>
>> Considering two neighbors N1 and N2, the line will be duplicated: one
>> N1->N2 and one N2->N1
>>
>
> Only if the neighbours are symmetric, and in graph-based or k-nearest
> neighbours, this is not the case.
>
>
>
>> Would you have any idea on how to select only one line from the two, for
>> example the first?
>>
>
> If the neighbours are symmetric, it would be possible to do for example:
>
> library(spdep)
> set.seed(1)
> xy <- cbind(x=runif(50), y=runif(50))
> nb <- dnearneigh(xy, 0, 0.2)
> nb
> is.symmetric.nb(nb)
> nb1 <- vector(mode="list", length=length(nb))
> for (i in seq(along=nb)) nb1[[i]] <- nb[[i]][nb[[i]] <= i]
> class(nb1) <- "nb"
> attr(nb1, "region.id") <- attr(nb, "region.id")
> nb1
>
> It could probably also be done with gEquals() in rgeos also for asymmetric
> neighbours to remove duplications where they occur.
>
> Roger
>
>
>  Actually, it would consist in removing duplicated lines with same geometry
>> but different directions.
>>
>>
>> Thanks in advance, any help would be greatly appreciated!
>>
>> Mathieu
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**_________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>>
>>
> --
> Roger Bivand
> Department of Economics, NHH Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand@nhh.no
>
>

	[[alternative HTML version deleted]]

