I have downloaded maps from a database that I want to plot in ggplot. The maps are all SpatialPolygonDataframes in class. My code produced rugged edges, so I tried to use a ksmooth function to the object. That helped a bit, but I still get some weird edges for some borders.
My code goes something like this
norway2 <- readOGR(dsn="path", use_iconv = TRUE, encoding = "UTF-8")
akershus <- #"Taking out" one county
q <- ggplot(data = merged, aes(x = long, y = lat, group = group))
q <- q + geom_polygon(color = "white", aes(fill = Ex),size = 0.05)
q <- q + scale_fill_gradient2(trans = "log", low = "white", high = "darkblue", guide = FALSE)
q <- q + theme(panel.background = element_rect(fill = "white", colour = "grey"),
panel.grid.major = element_line(colour = "white"))
q
This plot gives me something like
I have understood that I can smooth the object a little bit using something like
norway3_smooth <-smooth(norway3, method = "ksmooth", smoothness = 2.8)
This however is not really satisfactory. I get a plot like this, with some of the edges smoothed and others not.
Does anyone know of a way to smooth all the lines in a similar manner. Potentially using ggplot itself?