This markdown file will create maps that show the distribution of health facilities in Rio de Janeiro. The map will be sectioned off into neighborhood sections, as dicated by a shapefile that was imported and combined with numerical data.
The data on health establishments was found the City of Rio’s open data portal. You can find this dataset and others at the following site: http://data.rio/
I’ve previously worked with this data set to create an interactive map: http://rpubs.com/imcurtis/289903.
I’ve also written about this data set before, where my original project was to create static maps of the distribution of health establishments in individual neighborhoods: https://medium.com/@imcurtis/mapping-health-in-rio-de-janeiro-120d19d1b4e4
The goal of this project is to represent the concentration of health establishments in a particular neighborhood through a color scheme. We will see both the number of establishments per neighborhood, and the number of establishments per population of each neighborhood. We start by loading in the necessary libraries.
#Read the neighborhood shapefile data and plot
library(rgdal)
## Loading required package: sp
## rgdal: version: 1.2-8, (SVN revision 663)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.1.2, released 2016/10/24
## Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgdal/gdal
## Loaded PROJ.4 runtime: Rel. 4.9.1, 04 March 2015, [PJ_VERSION: 491]
## Path to PROJ.4 shared files: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgdal/proj
## Linking to sp version: 1.2-5
library(leaflet)
rj.neighborhoods <- readOGR("/Users/amcurtis91/Rio_Data_and_Analysis/Health_Rio/Limite_Bairro","Limite_Bairro+wgs84")
## OGR data source with driver: ESRI Shapefile
## Source: "/Users/amcurtis91/Rio_Data_and_Analysis/Health_Rio/Limite_Bairro", layer: "Limite_Bairro+wgs84"
## with 161 features
## It has 11 fields
## Integer64 fields read as strings: OBJECTID CODRA CODBNUM
From a previous project using this dataset, I had compiled a list of the number of health establishments per neighborhood. I combined this with population data for each neighborhood, and manually created a data set.
In this step, I merge that dataset with the @data slot of this shapefile.
csv <- read.csv("rj_merge.csv")
rj.neighborhoods@data = data.frame(rj.neighborhoods@data, csv[match(rj.neighborhoods@data$NOME, csv$NOME),])
head(rj.neighborhoods@data)
## OBJECTID Área NOME REGIAO_ADM AREA_PLANE
## 0 325 1705684.5 Paquetá PAQUETA 1
## 1 326 4056402.7 Freguesia (Ilha) ILHA DO GOVERNADOR 3
## 2 327 978046.6 Bancários ILHA DO GOVERNADOR 3
## 3 328 18957422.1 Galeão ILHA DO GOVERNADOR 3
## 4 329 1672545.7 Tauá ILHA DO GOVERNADOR 3
## 5 330 1186409.5 Portuguesa ILHA DO GOVERNADOR 3
## CODBAIRRO CODRA CODBNUM LINK SHAPESTAre
## 0 13 21 13 Paqueta&area=013 1705684.5
## 1 98 20 98 Freguesia (Ilha) &area=98 4056402.8
## 2 97 20 97 Bancários &area=97 978046.5
## 3 104 20 104 Galeão &area=104 18957422.2
## 4 101 20 101 Tauá &area=101 1672545.8
## 5 103 20 103 Portuguesa &area=103 1186409.4
## SHAPESTLen NOME.1 Populacao Amt_of_Estbl
## 0 24841.427 Paquetá 3361 0
## 1 18303.596 Freguesia (Ilha) 19437 0
## 2 7758.781 Bancários 12512 3
## 3 21510.059 Galeão 22971 4
## 4 8246.110 Tauá 29567 4
## 5 5101.523 Portuguesa 23856 11
Adding a new column that divides number of establishments by population.
rj.neighborhoods@data$Est_percapita <- rj.neighborhoods@data$Amt_of_Estbl/rj.neighborhoods@data$Populacao
head(rj.neighborhoods@data)
## OBJECTID Área NOME REGIAO_ADM AREA_PLANE
## 0 325 1705684.5 Paquetá PAQUETA 1
## 1 326 4056402.7 Freguesia (Ilha) ILHA DO GOVERNADOR 3
## 2 327 978046.6 Bancários ILHA DO GOVERNADOR 3
## 3 328 18957422.1 Galeão ILHA DO GOVERNADOR 3
## 4 329 1672545.7 Tauá ILHA DO GOVERNADOR 3
## 5 330 1186409.5 Portuguesa ILHA DO GOVERNADOR 3
## CODBAIRRO CODRA CODBNUM LINK SHAPESTAre
## 0 13 21 13 Paqueta&area=013 1705684.5
## 1 98 20 98 Freguesia (Ilha) &area=98 4056402.8
## 2 97 20 97 Bancários &area=97 978046.5
## 3 104 20 104 Galeão &area=104 18957422.2
## 4 101 20 101 Tauá &area=101 1672545.8
## 5 103 20 103 Portuguesa &area=103 1186409.4
## SHAPESTLen NOME.1 Populacao Amt_of_Estbl Est_percapita
## 0 24841.427 Paquetá 3361 0 0.0000000000
## 1 18303.596 Freguesia (Ilha) 19437 0 0.0000000000
## 2 7758.781 Bancários 12512 3 0.0002397698
## 3 21510.059 Galeão 22971 4 0.0001741326
## 4 8246.110 Tauá 29567 4 0.0001352860
## 5 5101.523 Portuguesa 23856 11 0.0004610999
Now we can create our maps. You can click on each neighborhood shape and see a popup with relevant information.
This map represents the number of health establishments in each neighborhood with a diverging color palette. The low and high extremes (red and green) are emphasized with dark and contrasting colors, while light colors represent the middle of the legend. Upon first glance, it looks like the majority of Rio’s health facilities are located in the central and western parts.
pal <- colorQuantile("RdYlGn", NULL, n = 5)
neighborhood_popup <- paste0("<strong>Neighborhood: </strong>",
rj.neighborhoods$NOME,
"<br><strong>Number of Establishments: </strong>",
rj.neighborhoods$Amt_of_Estbl)
leaflet() %>% setView(lng=-43.4303, lat=-22.8763, zoom = 10) %>%
addTiles() %>%
addPolygons(data = rj.neighborhoods,
fillColor = ~pal(Amt_of_Estbl),
fillOpacity = 0.8,
color = "#BDBDC3",
weight = 2,
popup = neighborhood_popup)
This map shows the number of health establishments per capita in each neighborhood. This map somewhat inverts the story of the previous map. It shows a high concentration of health care being provided in the Central and South Zones, as well as the developing Barra da Tijuca and the West Zone.
pal <- colorQuantile("RdYlGn", NULL, n = 5)
neighborhood_popup <- paste0("<strong>Neighborhood: </strong>",
rj.neighborhoods$NOME,
"<br><strong>Number of Establishments: </strong>",
rj.neighborhoods$Amt_of_Estbl,
"<br><strong>Population: </strong>",
rj.neighborhoods$Populacao,
"<br><strong>Establishments per capita: </strong>",
rj.neighborhoods$Est_percapita)
leaflet() %>% setView(lng=-43.4303, lat=-22.8763, zoom = 10) %>%
addTiles() %>%
addPolygons(data = rj.neighborhoods,
fillColor = ~pal(Est_percapita),
fillOpacity = 0.8,
color = "#BDBDC3",
weight = 2,
popup = neighborhood_popup)
And there are our maps. One can clearly identify areas that are lacking, perhaps severly, health establishments. It would be interesting to correlate this map with data on transportation routes in the city, in particular the subway and general public transit system.