I made a map of Brazilian cities using plot_brmap()
and I want to show the state border.
But I don't know how to do it.
What I have been trying:
library(brazilmaps)
library(maptools)
library(RColorBrewer)
# Define colors ----
createColors <- colorRampPalette(c("yellow","red","darkgreen"))
# Define city and states (shapefiles) ----
cidades_sp_mg <- get_brmap(geo = "City", geo.filter = list(State = c(31,35))
,class = "SpatialPolygonsDataFrame")
estados_sp_mg <- get_brmap(geo = "State", geo.filter = list(State = c(31,35))
,class = "SpatialPolygonsDataFrame")
# Create the city map ----
load(file="dados/data.Rdata")
dScore_data <- data %>% group_by(cod_municipio_ibge) %>% count()
# Merge city and shapefile
mapa_data <- plot_brmap(cidades_sp_mg,
data_to_join = dScore_data,
join_by = c("City" = "cod_municipio_ibge"),
var = "n"
)
# Create state map
mapa2_data <- plot_brmap(estados_sp_mg,
data_to_join = dScore_data,
join_by = c("State" = "code_state"),
)
MinhasCores_data <- createColors(4)
png("dados/Cities.png", width = 800, height = 600)
print(mapa_data) +
scale_fill_gradientn(colours=MinhasCores_data,name="Qtd.", na.value = "lightgray") +
labs(title="Cities",caption = "Font") +
theme(legend.title = element_text(face="bold"),title = element_text(face="bold"),
plot.title = element_text(hjust = 0.5,size=20),
plot.caption = element_text(hjust = 0.5,size = 10))
dev.off()
Any suggestions ?