I am using a code earlier posted by @jlhoward at Approaches for spatial geodesic latitude longitude clustering in R with geodesic or great circle distances
However, I am trying to implement the same thing for Sweden. When I load the shp file(s) I get an error from ggplots. How can I solve this? My code is below:
map.SE <- readOGR(dsn="sweden-latest", layer="places")
map.df <- fortify(map.SE)
ggplot(map.df)+
geom_path(aes(x=long, y=lat, group=group))+
geom_point(data=df, aes(x=long, y=lat, color=factor(clust)), size=4)+
scale_color_discrete("Cluster")+
coord_fixed()
The error that I get is at the "fortify" step - ggplot2 doesn't know how to deal with data of class SpatialPointsDataFrame