Date: 2016-04-22 18:00 Sender: Anthony FischachHere is a modest function that I wrote to side step the problem.
It restructures the SpatialLines to ensure that each 'Lines' object has one and only 'line', which is then assigned an arbitrary id.
Running this prior to offering a SpatialLines object to plotKML::kml_layer solves the problem.
This function would need to be extended to address data.frame objects.
## Reconstruct the spatialLines to ensure that each Line has an ID
MakeUniqueIds.sl<-function(SL){
listOfLines<-list()
n<-0
nLines<-length(slot(SL, 'lines'))
for(i in 1:nLines){
for(j in 1:length(SL@lines[[i]]@Lines)){
n<-n+1
listOfLines[n]<-SL@lines[[i]]@Lines[j]
}
}
ids<-seq(1:length(listOfLines))
LL<-list()
for(i in ids){
LL[i]<-Lines(listOfLines[i], i)
}
return(SpatialLines(LL, proj4string=prj.StudyArea))
} |