1. Introducción

Mediante el presente cuaderno se realizara la presentación de mapas temáticos del departamento de Nariño, estos mapas tendran como funcion mostrar informacion específica sobre cualquier tema para poder compartir e ilustrar la informacion pertinente. Para ello es importante obtener fuentes de informacion precisas y recientes que generen una mayor confiabilidad en los diversos temas.

Existen diversos mapas temáticos:

Mapas cloropletas

Utilizan colores o tramas para representar el área que ocupa un hecho. La intensidad del color o de la trama debe ser proporcional a la importancia del fenómeno.

Mapas de isolíneas

Usan líneas curvas que unen puntos de igual valor de un fenómeno. También se llaman mapas de isopletas. Se denominan isobaras si unen puntos con la misma presión atmosférica; isotermas en el caso de las temperaturas; isohipsa en el relieve (puntos con la misma altitud); isoyeta cuando estudiamos la precipitación, etc.

Mapas de diagramas

Superponen un mapa diagramas de barras, de sectores, etc.

Mapas de figuras

Utilizan figuras geométricas para localizar fenómenos puntuales. Su tamaño debe ser proporcional a la importancia del fenómeno.

Mapas de relieve estadístico

Es una cartografía elaborada por procedimientos informáticos de gran impacto visual; el valor de cada fenómeno se representa mediante relieves en forma de picos o depresiones, según dicho valor supere o no la media del fenómeno analizado.

2. Datos departamento de Nariño

Se trabajo con los datos obtenidos de Necesidades Básicas Insatisfechas (NBI) del Censo Nacional de Población y Vivienda 2018, el cual está disponible en el Geoportal del DANE.

Se realiza la debida separacion de los datos que queramos trabajar

3. Preparación

El primer paso es limpiar la memoria, seguido de la descarga de las librerias que se necesiten para el trabajo

#rm(list = ls())
list.of.packages <- c("tidyverse", "rgeos", "sf", "raster", "cartography", "SpatialPosition")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.3     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(readxl)
library(rgeos)
## Loading required package: sp
## rgeos version: 0.5-5, (SVN revision 640)
##  GEOS runtime version: 3.8.0-CAPI-1.13.1 
##  Linking to sp version: 1.4-2 
##  Polygon checking: TRUE
library(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(raster)
## 
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
## 
##     select
## The following object is masked from 'package:tidyr':
## 
##     extract
library(cartography)
library(SpatialPosition)

4. Lectura de los datos NBI

El siguiente paso es cargar los datos del departamento de Nariño del NBI recolectado por el DANE.

NBI_Nar <- read_excel("C:/Users/USER/Desktop/Geomatica/NBI_Nariño.xlsx")

Y se observan los atributos de los datos;

head(NBI_Nar)

Ahora, se debe de encontrar el municipio con el porcentaje de NBI más alto.

Max_NBI <- NBI_Nar %>% slice(which.max(NBI))
Max_NBI

Con el resultado que se obtubo es posible identificar que el municipio de Magüi tiene un NBI de 82.5% siendo el mas alto del departamento de Nariño. De la misma forma es posible conocer el municipio con menor NBI:

Min_NBI <- NBI_Nar %>% slice(which.min(NBI))
Min_NBI

SI se quisiera observar una mayor cantidad de datos, es posible organizarlo de manera descendente:

Desc_NBI <- NBI_Nar %>% arrange(desc(NBI))
Desc_NBI

5. Incorcorporacion de los datos del NBI a los municipios

Ahora se debe usar el shapefile correspondiente a los municipios del departamento de Nariño:

munic <- st_read("/Users/USER/Desktop/Geomatica/52_NARIÑO/ADMINISTRATIVO/MGN_MPIO_POLITICO.shp")
## Reading layer `MGN_MPIO_POLITICO' from data source `C:\Users\USER\Desktop\Geomatica\52_NARIÑO\ADMINISTRATIVO\MGN_MPIO_POLITICO.shp' using driver `ESRI Shapefile'
## Simple feature collection with 64 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -79.01021 ymin: 0.3613481 xmax: -76.83368 ymax: 2.683898
## geographic CRS: WGS 84
head(munic$MPIO_CCDGO)
## [1] "52683" "52685" "52687" "52560" "52693" "52565"

Se usa la funcion left_join para unir los municipios y los datos del NBI:

NBI_Munic <- left_join(munic, NBI_Nar, by=c("MPIO_CCDGO"="CODIGO"))
NBI_Munic %>%
  dplyr::select(MUNICIPIO, MPIO_CCDGO, NBI)  ->  Check_nbi_munic

head(Check_nbi_munic) 

Y se reproyecta los municipios

NBI_Munic_New <- st_transform(NBI_Munic, crs = 3116)

6. Ejemplos de mapas temáticos

Utilizaremos el paquete de cartografía que tiene como objetivo obtener mapas temáticos con la calidad visual de los que se construyen con un software de cartografía clásica o SIG.

6.1 OpenStreetMap Basemap y Símbolos Proporcionales

Mediante el uso getTiles el cual ayuda a crear mapas obtenidos de la base de OpenStreetMap, se establecen los parámetros del gráfico y las etiquetas para visualizar la variable NBI con círculos de diferentes tamaños, creando así un mapa proporcional o de símbolos graduados

Mun_osm <- getTiles(
x = NBI_Munic_New, 
type = "OpenStreetMap", 
zoom = 10,
cachedir = TRUE,
crop = FALSE
)
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): 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_defs
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
## datum WGS_1984 in CRS definition
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded 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_New), col = NA, border = "black", add=TRUE)

propSymbolsLayer(
  x = NBI_Munic_New, 
  var = "NBI", 
  inches = 0.1, 
  col = "red",
  legend.pos = "topright",  
  legend.title.txt = "Total NBI",
  legend.frame = T,
  legend.style = "e"
)

layoutLayer(title = "Distribucion del NBI en Nariño",
            sources = "Sources: DANE, 2018\n© OpenStreetMap",
            author = "Johnathan Moreno Rosero",
            frame = TRUE, north = FALSE, tabtitle = TRUE)

north(pos = "topleft")

6.2 Mapas cloropléticos

Para la realizacion del mapa de cloropletas, las areas presentan colores de acuerdo con la variable que se quiere representar. En este caso se hace uso de la función choroLayer() y de la funcion getBreaks() para la creacion de estos mapas.

opar <- par(mar = c(0,0,1.2,0))

par(bg="grey90")

plot(st_geometry(NBI_Munic_New), col = NA, border = NA, bg = "#aadaff")

choroLayer(
  x = NBI_Munic_New, 
  var = "NBI",
  method = "geom",
  nclass=5,
  col = carto.pal(pal1 = "sand.pal", n1 = 5),
  border = "white", 
  lwd = 0.5,
  legend.pos = "topright", 
  legend.title.txt = "NBI",
  add = TRUE
) 

layoutLayer(title = "Distribución de NBI en Nariño", 
            sources = "Source: DANE, 2018",
            author = "Johnathan Moreno Rosero", 
            frame = TRUE, north = TRUE, tabtitle = TRUE, col="black")

north(pos = "topleft")

6.3 Símbolos proporcionales y mapa tipológico

La función propSymbolsTypoLayer crea mapas de símbolos que son proporcionales de acuerdo a la primera variable y el color refleja la modalidad de la segunda variable cualitativa. El primer paso es crear la variable cualitativa y para ello se usa la función mutate

NBI_munic_2 <- dplyr::mutate(NBI_Munic_New, pobreza = ifelse(MISERIA > 20, "Extreme", 
                                                         ifelse(HACINAMIENTO > 5, "High", "Intermediate")))

Del codigo anterior se busca visualizar el atributo Pobreza

head(NBI_munic_2)
opar <- par(mar = c(0,0,1.2,0))

plot(st_geometry(NBI_munic_2), col="#f2efe9", border="#b38e43", bg = "#aad3df", 
     lwd = 0.5)

propSymbolsTypoLayer(
  x = NBI_munic_2, 
  var = "NBI", 
  inches = 0.3,
  symbols = "square",
  border = "white",
  lwd = .5,
  legend.var.pos = c(1050000, 1350000), 
  legend.var.title.txt = "NBI",
  var2 = "pobreza",
  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 = "Pobreza"
) 

layoutLayer(title="Distribución del NBI en Nariño", 
            author = "Johnathan Moreno Rosero", 
            sources = "Fuente: DANE, 2018", 
            scale = 1, tabtitle = TRUE, frame = TRUE)

north(pos = "topleft")

6.4 Mapas de etiquetas

Es posible combinar las funciones choroLayer y labelLayer:

opar <- par(mar = c(0,0,1.2,0))

par(bg="grey25")

plot(st_geometry(NBI_munic_2), col = "#e4e9de", border = "darkseagreen4", 
     bg = "grey75", lwd = 0.5)

choroLayer(
  x = NBI_Munic_New, 
  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_2, 
  txt = "MUNICIPIO", 
  col= "white", 
  cex = 0.4, 
  font = 4,
  halo = TRUE, 
  bg = "grey25", 
  r = 0.1, 
  overlap = FALSE, 
  show.lines = FALSE
)

layoutLayer(
  title = "Municipios de Nariño", 
  sources = "Fuente: DANE, 2018",  
  author = "Johnathan Moreno Rosero", 
  frame = TRUE,
  north = TRUE, 
  tabtitle = TRUE, 
  theme = "taupe.pal"
)

6.5 Mapas de isopletas

Estos mapas buscan generar modelos que indiquen ponderados a base de la distancia. Permite una representación espacial del fenómeno independiente de la heterogeneidad inicial de la división territorial. Para ello se hara uso de la función smoothLayer del paquete SpatialPosition.

crops2018 <- read_xlsx("C:/Users/USER/Desktop/Geomatica/EVA_NARINO1.xlsx")
head(crops2018)
colnames(crops2018)
##  [1] "COD_DEPTO"      "DEPTO"          "COD_MUN"        "MUN"           
##  [5] "GRUPO"          "SUBGRUPO"       "CULTIVO"        "ANO"           
##  [9] "PERIODO"        "AREA_SEMBRADA"  "AREA_COSECHADA" "PRODUCCION"    
## [13] "RENDIMIENTO"    "ESTADO"         "N_CIENTIFICO"   "CICLO"
names(crops2018) <-c("COD", "DEPARTAMENTO", "COD_MUN", "MUNICIPIO", 
                 "GRUPO", "SUBGRUPO", "CULTIVO", "S. PRODUCTIVO",
                 "YEAR", "AREA_SEM", "AREA_COSE",
                 "PRODUCCION", "RENDIMIENTO", "ESTADO", "NOMBRE",
                 "CICLO" )
colnames(crops2018)
##  [1] "COD"           "DEPARTAMENTO"  "COD_MUN"       "MUNICIPIO"    
##  [5] "GRUPO"         "SUBGRUPO"      "CULTIVO"       "S. PRODUCTIVO"
##  [9] "YEAR"          "AREA_SEM"      "AREA_COSE"     "PRODUCCION"   
## [13] "RENDIMIENTO"   "ESTADO"        "NOMBRE"        "CICLO"

Se filtran las filas que representan a los datos del cultivo de cafe debido a su notoria importancia en los ultimos años:

crops2018 %>%
  filter(CULTIVO == "CAFE", YEAR == 2018) -> cafe2018

cafe2018

Es importante crear un atributo que coincida con los códigos de los municipios:

cafe2018$MPIO_CCDGO <-  as.character(cafe2018$COD_MUN)

y se hace la union:

cafe_munic = left_join(munic, cafe2018, by="MPIO_CCDGO")
head(cafe_munic)

Ahora se reproyecta los municipios:

rep_cafe <- st_transform(cafe_munic, crs = 3116)
opar <- par(mar = c(0,0,1.2,0))

plot(st_geometry(cafe_munic), col = NA, border = "black", bg = "white")

smoothLayer(
  x = cafe_munic, 
  var = 'PRODUCCION',
  typefct = "exponential",
  span = 25000,
  beta = 2,
  nclass = 10,
  col = carto.pal(pal1 = 'orange.pal', n1 = 10),
  border = "black",
  lwd = 0.1, 
  mask = cafe_munic, 
  legend.title.txt = "Production",
  legend.pos = "topright", 
  add=TRUE
)
## Warning in st_centroid.sfc(st_geometry(knownpts), of_largest_polygon =
## all(st_is(knownpts, : st_centroid does not give correct centroids for longitude/
## latitude data
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
text(x = 650000, y = 1200000, cex = 0.6, adj = 0, font = 3,  labels = 
       "Distance function:\n- type = exponential\n- beta = 2\n- span = 20 km")

layoutLayer(title = "Producción de Cafe en Nariño",
            sources = "Fuente: DANE and MADR, 2018",
            author = "Johnathan Moreno Rosero",
            frame = FALSE, north = FALSE, tabtitle = TRUE, theme = "orange.pal")

north(pos = "topleft")

7. Guardar mapas

Para finalizar se trabajara en un ultimo mapa en el cual se visualize la produccion y rendimiento del Café durante el 2018 en Nariño. El mapa resultante se guardará como formato .png. Para esto hay que tener en cuenta que la función propSymbolsChoroLayer crea mapas de símbolos que son proporcionales a los valores de la primera variable y el color refleja la clasificación de la segunda variable, por lo tanto, se usará una combinación de propSymbolsLayer y choroLayer.

png("C:/Users/USER/Desktop/Geomatica/Cafe_2018.png", width = 2048, height = 1526)

opar <- par(mar = c(0,0,5,5))

plot(st_geometry(rep_cafe), col="darkseagreen3", border="black",  
     bg = "white", lwd = 0.6)

propSymbolsChoroLayer(x = rep_cafe, var = "PRODUCCION", var2 = "RENDIMIENTO",
                      col = carto.pal(pal1 = "green.pal", n1 = 3,
                                      pal2 = "red.pal", n2 = 3),
                      inches = 0.8, method = "q6",
                      border = "grey50", lwd = 1,
                      legend.title.cex = 1.5,
                      legend.values.cex = 1.0,
                      legend.var.pos = "right", 
                      legend.var2.pos = "left",
                      legend.var2.values.rnd = 2,
                      legend.var2.title.txt = "Rendimiento\n(in Ton/Ha)",
                      legend.var.title.txt = "Producción de Trigo en 2018",
                      legend.var.style = "e")

labelLayer(
  x = rep_cafe, 
  txt = "MPIO_CNMBR", 
  col= "white", 
  cex = 1.0, 
  font = 4,
  halo = FALSE, 
  bg = "white", 
  r = 0.1, 
  overlap = FALSE, 
  show.lines = FALSE
)

layoutLayer(title="Producción y Rendimiento de Trigo en 2018 en el departamento de Nariño",
            author = "Johnathan Moreno Rosero", 
            sources = "Fuente: MADR & DANE, 2018", 
            scale = 50, tabtitle = FALSE, frame = TRUE)

north(pos = "topleft")

title(main="Producción y Rendimiento de Cafe, 2018", cex.main=3,
      sub= "Fuente: MADR & DANE, 2018", cex.sub=2)

graticule = TRUE

par(opar)

dev.off()
## png 
##   2

Y obtenemos lo siguiente:

knitr::include_graphics("C:/Users/USER/Desktop/Geomatica/Cafe_2018.png")

8. Bibliiografia

IngeoSmart. (2019). ¿Qué es un Mapa Temático? Obtenido de: https://ingeo-smart.com/blog/f/%C2%BFqu%C3%A9-es-un-mapa-tem%C3%A1tico

Mapas Tematicos. (2014). obtenido de: http://mapastematicos6.blogspot.com/#:~:text=%2DExisten%20diversos%20tipos%20de%20mapas,igual%20valor%20de%20un%20fen%C3%B3meno.&text=%2DLos%20mapas%20de%20diagramas%20superponen,geom%C3%A9tricas%20para%20localizar%20fen%C3%B3menos%20puntuales