-1
library(tidyverse)
library(geobr)
Suppose I’m working with a Conservation Unit. Catimbau National Park (PE), for example.
Low data by package geobr
ucs<-read_conservation_units()
parna_catimbau <- ucs %>%
filter(str_detect(name_conservation_unit, "CATIMBAU"))
Then I plot the boundaries of Parna:
ggplot()+
geom_sf(data = parna_catimbau, col = "red", fill = "orange", alpha = .3)+
geom_sf_label(data = parna_catimbau, aes(label = name_conservation_unit))
What I’d like to know is if it’s possible through geom_sf(data= parna_catimbau)
get the geom_sf()
of neighbouring municipalities.
As I know that the Parna do Catimbau borders the municipality of Sertânia and covers the municipalities of Buíque, Ibimirim and Tupanatinga I can do manually:
First low data from the State of Pernambuco:
pe<-read_municipality(code_muni = "PE")
Then, I create an object with the said municipalities:
municipios_uc<-pe %>%
filter(name_muni %in% c ("Buíque", "Ibimirim", "Sertânia", "Tupanatinga"))
And then I put it all together:
ggplot()+
geom_sf(data = municipios_uc)+
geom_sf_text(data = municipios_uc, aes(label = name_muni))+
geom_sf(data = parna_catimbau, col = "red", fill = "orange", alpha = .3)+
geom_sf_label(data = parna_catimbau, aes(label = name_conservation_unit))
The end result is this:
However, as I said, I would like to know if there is a function that allows me to automatically plot the municipalities that relate to Catimbau National Park.
Perfect! Very grateful (once again)!
– itamar