将 shapefile 多边形添加到 Choropleth 地图 (Choroplethr)
Add shapefile Polygons to Choropleth Map (Choroplethr)
我想将包含多边形的 shapefile 添加到我使用 Choroplethr 包创建的等值线图。
等值线图是使用以下代码创建的:
choro=county_choropleth(Change, title= "WeeklyChange",
state_zoom = continental_us,reference_map = F)+
scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1",
"0"="snow","1"="greenyellow","2"="green","3"="green3"))
plot(choro)
gold= readShapePoly("Gold")
gold_df= fortify(gold)
land= ggplot(data= gold_df,aes(x=long, y= lat, group=group))+
geom_polygon(colour="gold3")
plot(gold)
两个对象都显示正确,但是我无法在等值线图上堆叠黄金地块。
Choropleth and gold map
提前致谢!
感谢 Ari Lamstein 帮助我。下面是添加多边形的代码
# Create Choropleth Map
`choro=county_choropleth(Change, title= "WeeklyChange",
state_zoom = continental_us,reference_map = F)+
scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1",
"0"="snow","1"="greenyellow","2"="green","3"="green3"))`
`#Import shapefile polygons
gold= readShapePoly("Gold")`
`#Create dataframe for ggplot
gold_df= fortify(gold)`
`#Combine Choropleth Map and shapefile dataframe
choro+geom_polygon(data= gold_df,aes(x=long, y= lat,group=group),fill="gold3")`
我想将包含多边形的 shapefile 添加到我使用 Choroplethr 包创建的等值线图。 等值线图是使用以下代码创建的:
choro=county_choropleth(Change, title= "WeeklyChange",
state_zoom = continental_us,reference_map = F)+
scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1",
"0"="snow","1"="greenyellow","2"="green","3"="green3"))
plot(choro)
gold= readShapePoly("Gold")
gold_df= fortify(gold)
land= ggplot(data= gold_df,aes(x=long, y= lat, group=group))+
geom_polygon(colour="gold3")
plot(gold)
两个对象都显示正确,但是我无法在等值线图上堆叠黄金地块。 Choropleth and gold map
提前致谢!
感谢 Ari Lamstein 帮助我。下面是添加多边形的代码
# Create Choropleth Map
`choro=county_choropleth(Change, title= "WeeklyChange",
state_zoom = continental_us,reference_map = F)+
scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1",
"0"="snow","1"="greenyellow","2"="green","3"="green3"))`
`#Import shapefile polygons
gold= readShapePoly("Gold")`
`#Create dataframe for ggplot
gold_df= fortify(gold)`
`#Combine Choropleth Map and shapefile dataframe
choro+geom_polygon(data= gold_df,aes(x=long, y= lat,group=group),fill="gold3")`