How to unlist spatial objects and plot altogether in R

梦想的初衷 提交于 2019-12-06 09:20:40

You need to put them all into one SpatialLines object. To do this you need to extract the Lines objects from each SpatialLines item in your list, then you can extract the individual lines objects from this, then you can use this list to recombine them into a single SpatialLines object:

#  Get the Lines objects which contain multiple 'lines'
ll0 <- lapply( SL1 , function(x) `@`(x , "lines") )

#  Extract the individual 'lines'
ll1 <- lapply( unlist( ll0 ) , function(y) `@`(y,"Lines") )

#  Combine them into a single SpatialLines object
Sl <- SpatialLines( list( Lines( unlist( ll1 ) , ID = 1 ) ) )

S4 classes!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!