Reputation: 1192
I'm having problems to overlay a shape file over a ggmap map.
The shape file is fine when I run it by itself, see pic below.
library(ggmap)
library(grid)
la <- get_map(location="Los Angeles County", zoom=9)
# get base map layer
gg <- ggmap(la)
library(broom)
LaCountyTracts <- CalifCensusTracts %>%
tidy(region = "GEOID") %>%
filter(grepl("06037", id))
ggplot(LaCountyTracts, aes(long, lat, group = group) ) +
geom_polygon( fill = "grey40",
colour = "grey90", alpha = .7, size = .05) +
coord_map() +
theme_minimal()
The code below produced the deformed shape layer when the ggmap and the shape file are combined.
gg + geom_polygon(data=LaCountyTracts,aes(x=long, y=lat,group=group),
colour = "grey90", alpha = .7, size = .05)
Upvotes: 1
Views: 703
Reputation: 1192
changed the line from
la <- get_map(location="Los Angeles County", zoom=9)
to
la <- get_map(location="Los Angeles County", zoom = 8)
and that fixed the problem
Upvotes: 0