I want to:
The desired outpu
Do they have to be part of the same legend? If not, then you could use the 'fill' aesthetic for the polygon and the 'colour' aesthetic for the line:
ggplot(dat, aes(x = x, y = y)) +
geom_polygon(aes(fill = "Border", group = id), colour="black") +
geom_line(data = line, aes(colour = "Line"), size = 1) +
scale_fill_manual(values=c(NA))