I need to rbind, in a loop, a load of SpatialPolygonDataFrames . These are created by buffering a roads file. However as my 'roads' file of class SpatialLinesDataFrame is 15000 rows long, the rbind function gets progressively slower. If they were data frames I would use rblindlist to speed things up. But that doesn't work with sp objects (right?). Does anyone have a good idea?
for (i in 1:nrow(roads)) {
temp <- gDifference(gBuffer(roads[i,], byid = T, width = 15, capStyle = 'ROUND'),
gBuffer(roads[i,], byid = T, width = 10, capStyle = 'ROUND'))
slot(slot(temp, "polygons")[[1]], "ID") <- as.character(roads[i,]$oid)
if (i == 1) {difference <- temp}
if (i > 1) {difference <- rbind(difference, temp)}
rm(temp)
print(i)
}
Thanks
James