5
I downloaded the data and plotted a map with the demographic density of the cities of the Metropolitan Region of São Paulo. But it is difficult to identify the cities.
rmsp <- readOGR("rmsp", "MunRM07", stringsAsFactors = F, encoding = "latin1")
rmsp_data <- rmsp@data
rmsp_poligonos <- rmsp@polygons
rmsp_projecao <- rmsp@proj4string
url_munic_15 <- "https://raw.githubusercontent.com/leobarone/FLS6397/master/data/planejamento_munic_2015.csv"
munic_15 <- read.table(url_munic_15, header = T, sep = ";") %>%
rename(COD_IBGE = A1, ano_pd = A18) %>%
select(COD_IBGE, ano_pd) %>%
mutate(ano_pd = as.numeric(as.character(ano_pd)))
rmsp@data <- rmsp@data %>%
mutate(ID = as.numeric(ID), COD_IBGE = as.numeric(COD_IBGE),
DENS_DEMO = as.numeric(DENS_DEMO)) %>%
left_join(munic_15, by = "COD_IBGE")
rmsp_df <- fortify(rmsp)
rmsp_df$id <- as.numeric(rmsp_df$id)
rmsp@data$id <- 0:(nrow(rmsp@data)-1)
rmsp_df <- left_join(rmsp_df, rmsp@data, by = "id")
ggplot(data = rmsp_df,
aes(x = long, y = lat, group = group, fill = DENS_DEMO)) +
geom_polygon() +
coord_map()
How to identify the places to get a sense of the positions on the map?