I am trying to build a lines shapefile with the contour lines from the 20 meters isobath from along the East African coast.
This contour line of 20 meters has different segments and I have this information on a list, and I am trying to convert this list into a shapefile and merging the different segments of the line.
How could I create a loop to join the different lines of the contour line?
library(maptools)
library(sp)
# ctlns: contour lines
ctlns
[[1]]
[[1]]$level
[1] -20
[[1]]$x
[1] 39.11667 39.10909 39.11667 39.12754 39.11667
[[1]]$y
[1] -5.327083 -5.316667 -5.303509 -5.316667 -5.327083
[[2]]
[[2]]$level
[1] -20
[[2]]$x
[1] 39.21667 39.20889 39.21667 39.21852 39.22667 39.23068 39.23333 39.24369 39.25000
[10] 39.25311 39.25173 39.25202 39.25000 39.23763 39.23333 39.22281 39.21667
[[2]]$y
[1] -5.053763 -5.050000 -5.035417 -5.033333 -5.016667 -5.000000 -4.998276 -4.983333
[9] -4.977907 -4.983333 -5.000000 -5.016667 -5.022381 -5.033333 -5.040000 -5.050000
[17] -5.053763
for(i in 1:length(ctlns))
{
ctlns[[i]]
isolines<- data.frame(ctlns[[i]])
iso <- cbind(isolines$x,isolines$y)
L1 <-Line(iso)
Ls1 = Lines(list(L1), ID = "a")
iso_spatial<-mapply(cbind, list(L1))
}
I am new using spatial data on R.