mardi 24 mars 2015

ggplot2 plots polygons with wrong topologies


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?





Aucun commentaire:

Enregistrer un commentaire