Skip to content
Prev 8890 / 29559 Next

change in sp::Lines() breaks example in my package

Michael, indeed a check was added recently to make sure that each Lines
colllection only has a single ID; I don't believe the array of IDs you
passed it had the effect you desired.

The short way out would be to have a simple

Lsl1 <- Lines(Ll1,"Streets")

but the nicer way assigns street IDs to individual streets:

i = 0
Lsl1 <- lapply(slist, function(x) {
	i <<- i+1
	Lines(Line(x), as.character(i))
})
rm(i)
Snow.streets.sp <- SpatialLines(Lsl1)

which now lets you index Snow.streets.sp, as in

Snow.streets.sp[100] # or
Snow.streets.sp["100"]

BTW it's the first time I advice someone to use <<- and I'd be happy for
a  suggestion to get rid of it!
On 07/27/2010 04:22 PM, Michael Friendly wrote: