Thanks Barry, it worked flawlessly. It is exactly what i wanted. On Mon, Sep 20, 2010 at 6:05 AM, Barry Rowlingson < b.rowling...@lancaster.ac.uk> wrote:
> > See the help for SpatialLines, Lines, Line, and > > SpatialLinesDataFrame... Or I might have a solution in half an hour... > > Bit quicker than half an hour... Try this - its a simpliified version > of ContourLines2SLDF that keeps the level lines separate: > > ContourLines2SLDF2 <- > function (cL, proj4string = CRS(as.character(NA))) > { > if (length(cL) < 1) > stop("cL too short") > > df <- data.frame(level = sapply(cL,function(x){x$level})) > m <- length(cL) > res <- vector(mode = "list", length = m) > IDs <- paste("C", 1:m, sep = "_") > row.names(df) <- IDs > for (i in 1:m) { > res[[i]] <- Lines(Line(cbind(cL[[i]]$x,cL[[i]]$y)), > ID = IDs[i]) > } > SL <- SpatialLines(res, proj4string = proj4string) > res <- SpatialLinesDataFrame(SL, data = df) > res > } > > -- > blog: http://geospaced.blogspot.com/ > web: > http://www.maths.lancs.ac.uk/~rowlings<http://www.maths.lancs.ac.uk/%7Erowlings> > web: http://www.rowlingson.com/ > twitter: http://twitter.com/geospacedman > pics: http://www.flickr.com/photos/spacedman > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo