我在ggmap地图上叠加形状文件时遇到问题。
当我单独运行时,形状文件很好,见下图。
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()
当组合ggmap和形状文件时,下面的代码会产生变形的形状图层。
gg + geom_polygon(data=LaCountyTracts,aes(x=long, y=lat,group=group),
colour = "grey90", alpha = .7, size = .05)
答案 0 :(得分:0)
从
更改了这一行la <- get_map(location="Los Angeles County", zoom=9)
到
la <- get_map(location="Los Angeles County", zoom = 8)
并修复了问题