[GIS] ggplot2 plots polygons with wrong topologies

ggplot2polygonrshapefile

I'm trying to plot polygons in R using ggplot2. In GRASS, QGIS and normal R the map renders fine, but ggplot2 seems to have some kind of topological difficultes I can't explain. With normal R it looks like this:

library(rgdal)
library(ggplot2)
regions <- readOGR(dir, layer)
plot(regions)

Plot with R

And with ggplot2:

ggplot() + geom_polygon(data=regions, aes(long, lat))

Plot with ggplot2

To add to the confusion, gplot2 is connecting polygons that have absolutely nothing to do with each other – Iceland to Ireland, for instance. How can I fix the plot?

Best Answer

A group aesthetic is missing:

ggplot() + geom_polygon(data=fortify(regions), aes(long, lat, group=group))

Otherwise the last point of a polygon is connected with the first point of the next polygon.

See also here: