as.list.polygon <- function(p) { if(is.matrix(p)) p <- data.frame(p,c("x","y")) p }