That's cool. Thanks Rolf and Adrian for your answers!
2011/11/17 Mathieu Rajerison <[email protected]> > That's cool. > > Thanks Rolf and Adrian for your answers! > > > 2011/11/17 Roger Bivand <[email protected]> > >> 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, [email protected] wrote: >> >> >>> Mathieu Rajerison <[email protected]> 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: [email protected] >> >> > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
