[R-sig-Geo] Tearing of polygons using ggmap & readOGR

Tyler Frazier tyler.j.frazier at icloud.com
Sun Jan 31 20:01:50 CET 2016


I'm trying to incorporate a simple shapefile of US states with ggmap and keep getting "tearing" of my polygons. I tried changing group=id to group=group which seemed to partially solve the problem, but not entirely.

library(rgdal)

states <- readOGR(dsn="shapefiles", layer="states")

proj4string(states)

[1] "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"

states <- spTransform(states, CRS("+proj=longlat +datum=WGS84"))

states <- fortify(states)

sstates <- get_map(location = c(-81, 35, -69, 45), zoom = 4, maptype = "watercolor")

sstates <- ggmap(sstates)

sstates <- sstates + geom_polygon(aes(x = long, y = lat, group=group), data = states, color ="white", fill ="orangered4", alpha = .4, size = .2)

Here is an image of the output.

http://pasteboard.co/1d7kiRfw.png <http://pasteboard.co/1d7kiRfw.png>


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list