That's cool.

Thanks Rolf and Adrian for your answers!

2011/11/17 Mathieu Rajerison <mathieu.rajerison@gmail.com>

> That's cool.
>
> Thanks Rolf and Adrian for your answers!
>
>
> 2011/11/17 Roger Bivand <Roger.Bivand@nhh.no>
>
>> Thanks to contributions by Adrian Baddeley, Rolf Turner and Mathieu
>> Rajerison, an S4 coercion method as(<psp-object>, "SpatialLines") and
>> function as.SpatialLines.psp() are committed to R-forge SVN in the maptools
>> project, and will be included in the next release of the maptools package.
>>
>> Roger
>>
>>
>> On Thu, 17 Nov 2011, Adrian.Baddeley@csiro.au wrote:
>>
>>
>>> Mathieu Rajerison <mathieu.rajerison@gmail.com> asks how to convert an
>>> object of class 'psp' in spatstat to an object of class SpatialLines in sp.
>>>
>>> Here is a function to do that. (It requires 'spatstat'.)
>>>
>>>
>>> as.SpatialLines.psp <- local({
>>>
>>>    ends2line <- function(x) Line(matrix(x, ncol=2, byrow=TRUE))
>>>    munch <- function(z) { Lines(ends2line(as.numeric(z[**1:4])),
>>> ID=z[5]) }
>>>
>>>    convert <- function(x) {
>>>       ends <- as.data.frame(x)[,1:4]
>>>       ends[,5] <- row.names(ends)
>>>       y <- apply(ends, 1, munch)
>>>       SpatialLines(y)
>>>    }
>>>    convert
>>> })
>>>
>>>
>>> ====
>>>
>>> Prof Adrian Baddeley (UWA/CSIRO)
>>> CSIRO Mathematics, Informatics & Statistics
>>> Leeuwin Centre, 65 Brockway Road, Floreat WA 6014, Australia
>>> Tel: 08 9333 6177 | Fax: 08 9333 6121 | Mob: 0410 447 821
>>> Skype: adrian.baddeley
>>>
>>>
>> --
>> 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]]

