我正在研究各种数据映射。其中一个感兴趣的地图是拍摄边界地图并将它们叠加在现有地图上。这些现有地图可能来自Google或其他来源。
我遇到的问题是当我使用geom_path()时,alpha<如图1所示,如果两个区域共享边界,则该边界比其他边界更暗。是否可以使所有边界具有相同的透明度?
library(ggplot2)
library(ggmap)
library(maptools)
library(plyr)
zips <- readShapePoly('cb_2016_us_zcta510_500k.shp')
test <- fortify(zips)
zips@data$id <- rownames(zips@data)
zips.points <- fortify(zips)
zips.df <- join(zips.points, zips@data, by = "id")
test_zips <- c(64002,64012,64013,64014,64015,64029,64030,64034,64050
,64051,64052,64053,64054,64055,64056,64057,64063,64064,64065,64070
,64075,64080,64081,64082,64083,64086,64108,64109,64110,64111,64112
,64113,64114,64121,64123,64124,64125,64126,64127,64128,64129,64130
,64131,64132,64133,64134,64136,64137,64138,64139,64141,64145,64146
,64147,64148,64149,64170,64171,64179,64191,64198,64999,66119,66160
,66205,66206,66207,66208,66209,66211,66222,66224,66251)
Valid_Zips <- zips.df[zips.df$GEOID10 %in% test_zips,]
mapImage <- get_map(location = c(lon = -94.4, lat = 38.9),
color = "color",
source = "google",
maptype = "toner-2011",
zoom = 10)
ggmap(mapImage) +
geom_path(aes(x = long, y = lat, group = group)
,color="red",data=Valid_Zips,size=1,alpha = .3)