Created
January 29, 2016 01:06
-
-
Save mdsumner/b9baaf74e57f33e209f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## wtf | |
#' Combine a list of PolygonDataFrame objects into a single object. | |
#' | |
#' Objects are combined by modifying sequential IDs to increase. | |
c_poly <- function(x) { | |
poly <- x[[1]] | |
if (length(x) == 1L) { | |
warning("input of length one, returning first element") | |
return(poly) | |
} | |
for (i in seq_along(x)[-1]) { | |
x0 <- spChFIDs(x[[i]], as.character(seq(nrow(x[[i]])) + max(as.integer(row.names(poly))))) | |
poly <- maptools::spRbind(poly, x0) | |
} | |
poly | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment