I have a census tiger line file for counties available from the Census website.
I am trying to display this file on a ggmap
, but fortify
seems to jumble the regions. I can't find anyone else who has run into this error, but I'm certainly not doing anything out of the ordinary...
library(maptools)
library(ggmap)
library(rgeos)
# read shapefile
WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0")
Counties <- readShapeSpatial("tl_2013_us_county.shp", proj4string = WGS84)
# limit to Ohio
Counties <- Counties[ Counties$STATEFP == 39, ]
# fortify
Counties.fort <- fortify(Counties, region = "GEOID")
# get base map and plot
OhioMap <- get_map("Ohio", source = 'google', maptype = 'terrain', zoom=7)
ggmap(OhioMap) + geom_polygon(aes(x=long, y=lat), fill = 'grey', alpha=0.4,
color = 'black', data = Counties.fort)