使用geom_sf制作带有一组子区域的地图 [英] Make a map with a group of subregions with geom_sf

查看:188
本文介绍了使用geom_sf制作带有一组子区域的地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想按子区域组制作带有外部边界的地图.贝娄已绘制了所有子区域的图,我只想绘制一个地图,但只绘制spain对象中region列中区域的外部边界.我已经尝试过像fillgroup这样的几个aes,甚至在进行绘制之前对其进行了分组,但找不到正确的方法:

I want to make a map only with the external borders by groups of subregions. Bellow are plotted all the subregions and I want to make a map but only with the external borders of the regions which are in region column in the spain object. I have tried with several aes like fill and group or even grouping by before plotting it but can't find a proper way:

library(rnaturalearth)
library(tidyverse)

spain <- ne_states(country = "spain", returnclass = "sf")

spain %>% 
  ggplot() +
  geom_sf()

reprex程序包(v0.2.1)于2019-02-12创建

Created on 2019-02-12 by the reprex package (v0.2.1)

仅在上面的地图中澄清区域是一组印刷形状:

Just to clarify regions are a group of printed shapes in the map above:

spain %>% 
  ggplot(aes(fill = region)) +
  geom_sf() +
  theme(legend.position = "none") 

reprex程序包(v0.2.1)于2019-02-12创建

Created on 2019-02-12 by the reprex package (v0.2.1)

推荐答案

group_byst_union都是选项:

spain %>% 
  group_by(region) %>% 
  summarise() %>% 
  ggplot(aes(fill = region)) +
  geom_sf() +
  theme(legend.position = 'none')

这篇关于使用geom_sf制作带有一组子区域的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆