因此,我正在尝试根据自定义变量创建带有边界的佛罗里达县级地图。我在此处包含了我正在尝试创建的旧版地图
从本质上讲,该地图显示了佛罗里达州各县的区域细分,媒体市场用粗体黑线边框勾勒。我能够很容易地绘制区域。我希望添加的是在媒体市场变量“MMarket”定义的区域之外的更粗的黑线边框,类似于上面显示的地图。填充变量将为 Region,媒体市场边界轮廓将使用 MMarket 定义。以下是读取和强化数据的方式:
#read in data
fl_data <- read_csv("Data for Mapping.csv")
#read in shapefiles
flcounties1 <- readOGR(dsn =".",layer = "Florida Counties")
#Fortify based on county name
counties.points <- fortify(flcounties1, region = "NAME")
counties.points$id <- toupper(counties.points$id)
#Merge plotting data and geospatial dataframe
merged <- merge(counties.points, merged_data, by.x="id", by.y="County", all.x=TRUE)
Run Code Online (Sandbox Code Playgroud)
该fl_data对象包含要映射的数据(包括媒体市场变量),并将 shapefile 数据读入flcounties1. 这是我正在使用的合并数据框的示例:
head(merged %>% select(id:group, Region, MMarket))
id long lat order hole piece group Region MMarket
1 ALACHUA -82.65855 29.83014 1 FALSE 1 Alachua.1 …Run Code Online (Sandbox Code Playgroud)