Este cuaderno presenta mapas temáticos del departamento de Boyacá, con los mapas temáticos podemos mostrar información específica sobre cualquier tema para que podamos ilustrar la información con la audiencia que la vamos a compartir. Hay varias técnicas utilizadas en el mapeo temático que vamos a revisar a través de este cuaderno.
library(tidyverse)
library(readxl)
library(rgeos)
library(raster)
library(sf)
library(cartography)
library(SpatialPosition)
library(dplyr)
Ahora cargamos los datos, que previamente fueron filtrados y copiados a un nuevo archivo para nuestro departamento a partir de los datos de Necesidades Básicas Insatisfechas (NBI) del Censo Nacional de Población y Vivienda 2018 que se pueden descargar aquí.
NBI_Boyaca <- read_excel("C:/Users/David Perdomo/Desktop/NBI_Boyacá.xlsx")
head(NBI_Boyaca)
Debido a que la columna COD es una variable de tipo double, nescesitamos convertirla a tipo character para lo cual usamos la funcion as.character y observamos de nuevo los primeros atributos del data.frame nbi:
NBI_Boyaca$COD <- as.character(NBI_Boyaca$COD)
head(NBI_Boyaca)
Usamos la funcion slice para clasificar el municipio con mayor porcentaje de NBI, guardamos los datos en un obtejo de tipo data.frame que llamamos max_nbi:
max_nbi <- NBI_Boyaca %>%
slice(which.max(NBI))
max_nbi
obtuvimos que el mayor porcentaje de NBI se registro en el municipio de PAYA.
Busquemos cual es el municipio con el porcentaje mas bajo de NBI: guardamos los datos en un objeto de tipo data.frame que llamamos min_nbi:
min_nbi <- NBI_Boyaca %>%
slice(which.min(NBI))
min_nbi
el menor porcentaje de NBI se registro en el municipio de SOGAMOSO. Clasifiquemos los municipios por NBI en orden descendente: Usamos la funcion arrange para clasificar los municipios en orden descendente de acuerdo al porcentaje de NBI, almacenamos los nuevos datos en un objeto de tipo data.frame, que llamamos desc_nbi:
desc_nbi <- NBI_Boyaca %>%
arrange(desc(NBI))
desc_nbi
Leemos los datos del Marco Geoestadistico Departamental descargado de DANE Geoportal, usando la libreria sf y los almacenamos en un nuevo data.frame que llamaremos BOY_munic:
munic <- st_read("C:/Users/David Perdomo/Desktop/Geomatica/15_BOYACA/ADMINISTRATIVO/MGN_MPIO_POLITICO.shp")
Reading layer `MGN_MPIO_POLITICO' from data source `C:\Users\David Perdomo\Desktop\Geomatica\15_BOYACA\ADMINISTRATIVO\MGN_MPIO_POLITICO.shp' using driver `ESRI Shapefile'
Simple feature collection with 123 features and 9 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: -74.66496 ymin: 4.655196 xmax: -71.94885 ymax: 7.055557
geographic CRS: WGS 84
Observamos los primeros Municipios usando la funcion head, e indicando que queremos leer el data.frame BOY_munic y usamos el signo $ para indicar que solo queremos ver los datos de la columna MPIO_CCDGO, la cual contiene los nombres municipales.
head(BOY_munic$MPIO_CNMBR)
[1] "TUNJA" "ALMEIDA" "AQUITANIA" "ARCABUCO" "BELÉN"
[6] "BERBEO"
Usamos left_join para unir los municipios y los datos de NBI en un data.frame que llamamos nbi_munic.
NBI_Munic <- left_join(munic, NBI_Boyaca, by=c("MPIO_CCDGO"="COD"))
head(NBI_Munic)
Simple feature collection with 6 features and 20 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: -73.51402 ymin: 4.904038 xmax: -72.65243 ymax: 6.098348
geographic CRS: WGS 84
DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR
1 15 15001 TUNJA
2 15 15022 ALMEIDA
3 15 15047 AQUITANIA
4 15 15051 ARCABUCO
5 15 15087 BELÉN
6 15 15090 BERBEO
MPIO_CRSLC MPIO_NAREA MPIO_NANO
1 1541 119.68957 2017
2 1908 57.67212 2017
3 1789 942.14660 2017
4 1856 137.89859 2017
5 1756 163.08822 2017
6 Ordenanza 28 de Abril 9 de 1913 58.01301 2017
DPTO_CNMBR Shape_Leng Shape_Area COD_DEP DEPTO COD_MUNI
1 BOYACÁ 0.5723744 0.009766301 15 BOYACÁ 1
2 BOYACÁ 0.3484692 0.004701759 15 BOYACÁ 22
3 BOYACÁ 1.8003115 0.076843504 15 BOYACÁ 47
4 BOYACÁ 0.7527090 0.011256738 15 BOYACÁ 51
5 BOYACÁ 0.6293489 0.013314920 15 BOYACÁ 87
6 BOYACÁ 0.4291743 0.004730850 15 BOYACÁ 90
MUNI NBI MISERIA VIVIENDA SERVICIOS
1 TUNJA 3.596644 0.2936770 0.3326341 0.2373389
2 ALMEIDA 7.458913 0.7585335 1.5802781 0.8217446
3 AQUITANIA 12.864358 1.6738817 1.7099567 3.6147186
4 ARCABUCO 8.940701 0.4773270 0.4589682 0.1835873
5 BELÉN 7.334062 0.6965310 0.3414368 1.0243103
6 BERBEO 15.048544 2.7045770 5.7558946 1.7337032
HACINAMIENTO INASISTENCIA ECONOMIA
1 0.9835181 0.6209170 1.769853
2 1.3274336 1.2010114 3.286979
3 3.4632035 1.4357864 4.523810
4 2.2948412 4.3143015 2.166330
5 2.0349631 0.5736138 4.110899
6 1.0402219 1.3176144 8.460472
geometry
1 POLYGON ((-73.34014 5.58308...
2 POLYGON ((-73.36793 5.01349...
3 POLYGON ((-72.76242 5.63856...
4 POLYGON ((-73.50487 5.84347...
5 POLYGON ((-72.91692 6.08612...
6 POLYGON ((-73.0677 5.27048,...
Comprobemos que los datos se han unido de la forma correcta comprobando el NBI; aquí usamos un comando un poco poco común dplyr :: select; este se usa porque select es el nombre de una función en algunos de los paquetes que estamos usando aquí, por lo que necesitamos especificar que queremos usar la función select del paquete dplyr. Después de eso, configuraremos el sistema de referencia para nuestros datos.
NBI_Munic %>%
dplyr::select(COD_MUNI, MPIO_CCDGO, NBI) -> Check_nbi_munic
Check_nbi_munic
Simple feature collection with 123 features and 3 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: -74.66496 ymin: 4.655196 xmax: -71.94885 ymax: 7.055557
geographic CRS: WGS 84
First 10 features:
COD_MUNI MPIO_CCDGO NBI geometry
1 1 15001 3.596644 POLYGON ((-73.34014 5.58308...
2 22 15022 7.458913 POLYGON ((-73.36793 5.01349...
3 47 15047 12.864358 POLYGON ((-72.76242 5.63856...
4 51 15051 8.940701 POLYGON ((-73.50487 5.84347...
5 87 15087 7.334062 POLYGON ((-72.91692 6.08612...
6 90 15090 15.048544 POLYGON ((-73.0677 5.27048,...
7 92 15092 10.870712 POLYGON ((-72.81796 5.97422...
8 97 15097 19.059205 POLYGON ((-72.64907 6.43640...
9 104 15104 11.091234 POLYGON ((-73.34806 5.47411...
10 106 15106 16.005874 POLYGON ((-73.89118 5.73749...
NBI_Munic_Proj <- st_transform(NBI_Munic, crs = 3116)
Hagamos nuestro primer mapa usando la función getTiles para obtener el mapa base de OpenStreetMap, luego establecemos los márgenes para el gráfico y todas las etiquetas para visualizar el NBI con círculos rojos de diferentes tamaños, conocido como mapa de símbolos proporcionales o graduados.
Mun_osm <- getTiles(
x = NBI_Munic_Proj,
type = "OpenStreetMap",
zoom = 10,
cachedir = TRUE,
crop = FALSE
)
Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defsDiscarded datum WGS_1984 in CRS definitionDiscarded datum Unknown based on GRS80 ellipsoid in CRS definition,
but +towgs84= values preservedDiscarded datum Unknown based on GRS80 ellipsoid in CRS definition,
but +towgs84= values preservedDiscarded datum Unknown based on GRS80 ellipsoid in CRS definition,
but +towgs84= values preserved
opar <- par(mar = c(0,0,1.2,0))
tilesLayer(x = Mun_osm)
plot(st_geometry(NBI_Munic_Proj), col = NA, border = "grey", add=TRUE)
propSymbolsLayer(
x = NBI_Munic_Proj,
var = "NBI",
inches = 0.1,
col = "red",
legend.pos = "topright",
legend.title.txt = "Total NBI",
legend.frame = T,
legend.style = "e"
)
layoutLayer(title = "NBI Distribución en Boyacá",
sources = "Sources: DANE, 2018\n© OpenStreetMap",
author = "Jorge Perdomo",
frame = TRUE, north = FALSE, tabtitle = TRUE)
north(pos = "topleft")
Ahora no vamos a utilizar OpenStreetMap Background y trazar el NBI con diferentes intensidades de color, lo que también se conoce como mapeo de coropletas.
opar <- par(mar = c(0,0,1.2,0))
par(bg="grey90")
plot(st_geometry(NBI_Munic_Proj), col = NA, border = NA, bg = "#aadaff")
choroLayer(
x = NBI_Munic_Proj,
var = "NBI",
method = "geom",
nclass=5,
col = carto.pal(pal1 = "orange.pal", n1 = 5),
border = "white",
lwd = 0.5,
legend.pos = "topright",
legend.title.txt = "NBI",
add = TRUE
)
layoutLayer(title = "NBI Distribución en Boyacá",
sources = "Source: DANE, 2018",
author = "Jorge Perdomo",
frame = TRUE, tabtitle = TRUE, col="black")
north(pos = "topleft")
Ahora vamos a crear una nueva variable creando una nueva categoría llamada Pobreza usando las categorías Miseria y Hacinamiento.
NBI_Munic_Proj2 <- dplyr::mutate(NBI_Munic_Proj, poverty=ifelse(MISERIA > 20, "Extreme", ifelse(HACINAMIENTO > 5, "High", "Intermediate")))
NBI_Munic_Proj2
Simple feature collection with 123 features and 21 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 934932.9 ymin: 1006592 xmax: 1235253 ymax: 1272398
projected CRS: MAGNA-SIRGAS / Colombia Bogota zone
First 10 features:
DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR
1 15 15001 TUNJA
2 15 15022 ALMEIDA
3 15 15047 AQUITANIA
4 15 15051 ARCABUCO
5 15 15087 BELÉN
6 15 15090 BERBEO
7 15 15092 BETÉITIVA
8 15 15097 BOAVITA
9 15 15104 BOYACÁ
10 15 15106 BRICEÑO
MPIO_CRSLC MPIO_NAREA MPIO_NANO
1 1541 119.68957 2017
2 1908 57.67212 2017
3 1789 942.14660 2017
4 1856 137.89859 2017
5 1756 163.08822 2017
6 Ordenanza 28 de Abril 9 de 1913 58.01301 2017
7 1754 101.89955 2017
8 1613 145.30529 2017
9 1537 48.02287 2017
10 Ordenanza 14 del 25 de Julio de 1890 64.59970 2017
DPTO_CNMBR Shape_Leng Shape_Area COD_DEP DEPTO COD_MUNI
1 BOYACÁ 0.5723744 0.009766301 15 BOYACÁ 1
2 BOYACÁ 0.3484692 0.004701759 15 BOYACÁ 22
3 BOYACÁ 1.8003115 0.076843504 15 BOYACÁ 47
4 BOYACÁ 0.7527090 0.011256738 15 BOYACÁ 51
5 BOYACÁ 0.6293489 0.013314920 15 BOYACÁ 87
6 BOYACÁ 0.4291743 0.004730850 15 BOYACÁ 90
7 BOYACÁ 0.4738184 0.008317810 15 BOYACÁ 92
8 BOYACÁ 0.6597822 0.011867743 15 BOYACÁ 97
9 BOYACÁ 0.3256140 0.003918022 15 BOYACÁ 104
10 BOYACÁ 0.4849753 0.005273255 15 BOYACÁ 106
MUNI NBI MISERIA VIVIENDA SERVICIOS
1 TUNJA 3.596644 0.2936770 0.3326341 0.2373389
2 ALMEIDA 7.458913 0.7585335 1.5802781 0.8217446
3 AQUITANIA 12.864358 1.6738817 1.7099567 3.6147186
4 ARCABUCO 8.940701 0.4773270 0.4589682 0.1835873
5 BELÉN 7.334062 0.6965310 0.3414368 1.0243103
6 BERBEO 15.048544 2.7045770 5.7558946 1.7337032
7 BETÉITIVA 10.870712 1.4775726 0.7915567 2.0580475
8 BOAVITA 19.059205 3.2643958 1.1962693 6.8329278
9 BOYACÁ 11.091234 0.8273703 0.7826476 0.8050089
10 BRICEÑO 16.005874 2.0558003 2.9858052 1.3215859
HACINAMIENTO INASISTENCIA ECONOMIA
1 0.9835181 0.6209170 1.769853
2 1.3274336 1.2010114 3.286979
3 3.4632035 1.4357864 4.523810
4 2.2948412 4.3143015 2.166330
5 2.0349631 0.5736138 4.110899
6 1.0402219 1.3176144 8.460472
7 3.7994723 0.7387863 5.171504
8 7.3600973 0.8718573 6.792376
9 2.9964222 0.9838998 6.440072
10 4.4542340 0.3426334 9.495839
geometry poverty
1 POLYGON ((1081699 1109184, ... Intermediate
2 POLYGON ((1078692 1046187, ... Intermediate
3 POLYGON ((1145704 1115432, ... Intermediate
4 POLYGON ((1063418 1137961, ... Intermediate
5 POLYGON ((1128481 1164899, ... Intermediate
6 POLYGON ((1111945 1074654, ... Intermediate
7 POLYGON ((1139466 1152547, ... Intermediate
8 POLYGON ((1158033 1203719, ... High
9 POLYGON ((1080836 1097132, ... Intermediate
10 POLYGON ((1020639 1126211, ... Intermediate
Aquí vamos a hacer un mapa usando las categorías NBI y Pobreza juntas.
library(sf)
library(cartography)
opar <- par(mar = c(0,0,1.2,0))
plot(st_geometry(NBI_Munic_Proj2), col="#f2efe9", border="#b38e43", bg = "#aad3df",
lwd = 0.5)
propSymbolsTypoLayer(
x = NBI_Munic_Proj2,
var = "NBI",
inches = 0.3,
symbols = "square",
border = "white",
lwd = .5,
legend.var.pos = c(1050000, 1350000),
legend.var.title.txt = "NBI",
var2 = "poverty",
legend.var2.values.order = c("Extreme", "High",
"Intermediate"),
col = carto.pal(pal1 = "multi.pal", n1 = 3),
legend.var2.pos = c(1050000, 1200000),
legend.var2.title.txt = "Poverty"
)
layoutLayer(title="NBI y distribución de la pobreza en Boyacá",
author = "Jorge Perdomo",
sources = "Source: DANE, 2018",
scale = 1, tabtitle = TRUE, frame = TRUE)
north(pos = "topleft")
Ahora tracemos el NBI con los nombres de los municipios de nuestro departamento.
opar <- par(mar = c(0,0,1.2,0))
par(bg="grey25")
plot(st_geometry(NBI_Munic_Proj2), col = "#e4e9de", border = "darkseagreen4", bg = "grey75")
choroLayer(
x = NBI_Munic_Proj2,
var = "NBI",
method = "geom",
nclass=5,
col = carto.pal(pal1 = "orange.pal", n1 = 5),
border = "white",
lwd = 0.5,
legend.pos = "topright",
legend.title.txt = "NBI",
add = TRUE
)
labelLayer(
x = NBI_Munic_Proj2,
txt = "MUNI",
col= "white",
cex = 0.3,
font = 4,
halo = TRUE,
bg = "grey25",
r = 0.05,
overlap = FALSE,
show.lines = FALSE
)
layoutLayer(
title = "Municipios y NBI de Boyacá",
sources = "Source: DANE, 2018",
author = "Jorge Perdomo",
frame = TRUE,
tabtitle = TRUE,
theme = "taupe.pal"
)
north(pos = "topleft")