#Introduccion ## La cartografia tematica es de gran importancia en diferentes areas del conocimiento, ya que nos permite transmitir determinada informacion de una region mediante formas, colores y graficos que sean faciles de asimilar por parte del usuario, en este cuaderno, veremos diferentes ejemplos de mapas tematicos aplicados hacia el departamento de santander, especificamente hacia datos obtenidos en los ultimos años sobre aspectos sociales y agricolas de la zona
rm(list=ls())
list.of.packages <- c("tidyverse", "rgeos", "sf", "raster", "cartography", "SpatialPosition","rgdal")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
library(rgdal)
## Loading required package: sp
## rgdal: version: 1.4-8, (SVN revision 845)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
## Path to GDAL shared files: C:/Users/juane/Documents/R/win-library/4.0/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
## Path to PROJ.4 shared files: C:/Users/juane/Documents/R/win-library/4.0/rgdal/proj
## Linking to sp version: 1.4-1
library(tidyverse)
## -- Attaching packages ------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.0 v purrr 0.3.4
## v tibble 3.0.1 v dplyr 0.8.5
## v tidyr 1.0.3 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(rgeos)
## rgeos version: 0.5-3, (SVN revision 634)
## GEOS runtime version: 3.8.0-CAPI-1.13.1
## Linking to sp version: 1.4-1
## 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)
library(readxl)
NBI<-read_excel("./2018-NBI.xlsx")
NBI
## # A tibble: 87 x 12
## COD_DPTO DEPTO COD_MUN CODIGO MUN NBI MISERIA VIVIENDA SERVICIOS
## <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 68 SANT~ 001 68001 BUCA~ 5.38 0.597 0.867 0.352
## 2 68 SANT~ 013 68013 AGUA~ 16.1 1.82 0.667 1.03
## 3 68 SANT~ 020 68020 ALBA~ 15.5 1.87 1.97 2.48
## 4 68 SANT~ 051 68051 ARAT~ 19.9 3.66 3.49 3.88
## 5 68 SANT~ 077 68077 BARB~ 7.99 1.06 1.07 0.202
## 6 68 SANT~ 079 68079 BARI~ 11.0 0.687 0.634 0.489
## 7 68 SANT~ 081 68081 BARR~ 11.6 1.81 5.45 0.266
## 8 68 SANT~ 092 68092 BETU~ 21.5 3.55 10.2 2.91
## 9 68 SANT~ 101 68101 BOLÍ~ 25.7 4.63 9.49 2.77
## 10 68 SANT~ 121 68121 CABR~ 12.8 0.935 1.37 0.374
## # ... with 77 more rows, and 3 more variables: HACINAMIENTO <dbl>,
## # INASISTENCIA <dbl>, ECONOMIA <dbl>
NBI %>%
slice(which.max(NBI)) -> max_NBI
max_NBI
## # A tibble: 1 x 12
## COD_DPTO DEPTO COD_MUN CODIGO MUN NBI MISERIA VIVIENDA SERVICIOS
## <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 68 SANT~ 235 68235 EL C~ 43.0 9.70 32.7 4.97
## # ... with 3 more variables: HACINAMIENTO <dbl>, INASISTENCIA <dbl>,
## # ECONOMIA <dbl>
NBI %>%
arrange(desc(NBI)) -> desc_NBI
desc_NBI
## # A tibble: 87 x 12
## COD_DPTO DEPTO COD_MUN CODIGO MUN NBI MISERIA VIVIENDA SERVICIOS
## <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 68 SANT~ 235 68235 EL C~ 43.0 9.70 32.7 4.97
## 2 68 SANT~ 575 68575 PUER~ 32.1 8.44 23.7 5.28
## 3 68 SANT~ 250 68250 EL P~ 31.9 7.37 9.74 5.37
## 4 68 SANT~ 271 68271 FLOR~ 31.3 7.05 8.59 9.68
## 5 68 SANT~ 152 68152 CARC~ 27.2 4.65 1.48 4.84
## 6 68 SANT~ 255 68255 EL P~ 27.2 8.46 13.1 6.21
## 7 68 SANT~ 468 68468 MOLA~ 26.5 6.64 0.792 9.09
## 8 68 SANT~ 684 68684 SAN ~ 26.2 5.52 2.49 2.27
## 9 68 SANT~ 502 68502 ONZA~ 25.9 4.43 1.20 7.26
## 10 68 SANT~ 101 68101 BOLÍ~ 25.7 4.63 9.49 2.77
## # ... with 77 more rows, and 3 more variables: HACINAMIENTO <dbl>,
## # INASISTENCIA <dbl>, ECONOMIA <dbl>
munic <- st_read("./marco geoestadisitico/68_SANTANDER/ADMINISTRATIVO/MGN_MPIO_POLITICO.shp")
## Reading layer `MGN_MPIO_POLITICO' from data source `D:\unal\geomatica\santander\marco geoestadisitico\68_SANTANDER\ADMINISTRATIVO\MGN_MPIO_POLITICO.shp' using driver `ESRI Shapefile'
## Simple feature collection with 87 features and 9 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -74.52895 ymin: 5.707536 xmax: -72.47706 ymax: 8.14501
## geographic CRS: WGS 84
munic
## Simple feature collection with 87 features and 9 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -74.52895 ymin: 5.707536 xmax: -72.47706 ymax: 8.14501
## geographic CRS: WGS 84
## First 10 features:
## DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR MPIO_CRSLC
## 1 68 68001 BUCARAMANGA 1623
## 2 68 68013 AGUADA 1775
## 3 68 68020 ALBANIA Ordenanza 33 de 1919
## 4 68 68051 ARATOCA 1750
## 5 68 68077 BARBOSA Ordenanza 30 del 25 de Abril de 1936
## 6 68 68079 BARICHARA 1799
## 7 68 68081 BARRANCABERMEJA Ordenanza 13 del 17 de Abril de 1922
## 8 68 68092 BETULIA 1874
## 9 68 68101 BOLIVAR 1844
## 10 68 68121 CABRERA 1869
## MPIO_NAREA MPIO_NANO DPTO_CNMBR Shape_Leng Shape_Area
## 1 152.90497 2017 SANTANDER 0.6922752 0.012513526
## 2 75.23125 2017 SANTANDER 0.4758098 0.006146093
## 3 166.21697 2017 SANTANDER 0.8761299 0.013570466
## 4 169.79155 2017 SANTANDER 0.6746922 0.013882031
## 5 46.66489 2017 SANTANDER 0.2703415 0.003810882
## 6 137.27581 2017 SANTANDER 0.5610888 0.011223345
## 7 1326.83512 2017 SANTANDER 2.7351901 0.108590745
## 8 431.24871 2017 SANTANDER 1.2718180 0.035286963
## 9 1010.11035 2017 SANTANDER 4.3603864 0.082514928
## 10 65.57431 2017 SANTANDER 0.3515706 0.005360404
## geometry
## 1 POLYGON ((-73.08418 7.23063...
## 2 POLYGON ((-73.56261 6.24032...
## 3 POLYGON ((-73.73616 5.87092...
## 4 POLYGON ((-72.98158 6.76065...
## 5 POLYGON ((-73.58988 5.99809...
## 6 POLYGON ((-73.22126 6.73288...
## 7 POLYGON ((-73.6939 7.254447...
## 8 POLYGON ((-73.53993 7.15392...
## 9 POLYGON ((-74.50132 6.27574...
## 10 POLYGON ((-73.25696 6.6213,...
NBI_munic = left_join(munic, NBI, by=c("MPIO_CCDGO"="CODIGO"))
NBI_munic %>%
dplyr::select(MUN, MPIO_CCDGO, NBI) -> check_NBI_munic
head(check_NBI_munic)
## Simple feature collection with 6 features and 3 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -73.96194 ymin: 5.707536 xmax: -72.93536 ymax: 7.266616
## geographic CRS: WGS 84
## MUN MPIO_CCDGO NBI geometry
## 1 BUCARAMANGA 68001 5.384333 POLYGON ((-73.08418 7.23063...
## 2 AGUADA 68013 16.070346 POLYGON ((-73.56261 6.24032...
## 3 ALBANIA 68020 15.542788 POLYGON ((-73.73616 5.87092...
## 4 ARATOCA 68051 19.933851 POLYGON ((-72.98158 6.76065...
## 5 BARBOSA 68077 7.985664 POLYGON ((-73.58988 5.99809...
## 6 BARICHARA 68079 10.962885 POLYGON ((-73.22126 6.73288...
###los datos geograficos estaban en base al sistema geografico WGS 84, pero para esta practica, se usara como referencia el sistema, 3116, el cual hace referencia al sistema MAGNA
NBI_munic_new <- st_transform(NBI_munic, crs = 3116)
mun.osm <- getTiles(
x = NBI_munic_new,
type = "OpenStreetMap",
zoom = 8,
cachedir = TRUE,
crop = FALSE
)
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.18,
col = "brown4",
legend.pos = "topright",
legend.title.txt = "Total NBI"
)
layoutLayer(title = " NBI Distribution in Santander",
sources = "Sources: DANE, 2018\n© OpenStreetMap",
author = " Juan Castilla",
frame = TRUE, north = FALSE, tabtitle = TRUE)
north(pos = "topleft")
### El sigueinte mapa a realizar es el llamado mapa de coropletas, el cual consiste en que las diferentes regiones del mapa seran pintadas de un cierto color de una gama de tonos determinada acorde al valor asignado de la variable a analizar, y a diferencia del anterior, donde los puntos no eran muy conclluyentes sobre la informacion, este es mas claro con la informacion que quiere transmitir. Aqui se confirma lo visto en el mapa anterior, los colores azules oscuros en la zona media del departamento muestran niveles medianos-altos de necesidades basicas insatisfechas en la region
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=10,
col = carto.pal(pal1 = "turquoise.pal", n1 = 10),
border = "white",
lwd = 0.5,
legend.pos = "topright",
legend.title.txt = "NBI",
add = TRUE
)
layoutLayer(title = "NBI Distribution in Santander",
sources = "Source: DANE, 2018",
author = "Juan Castilla",
frame = TRUE, north = TRUE, tabtitle = TRUE, col="black")
north(pos = "topleft")
### para el siguiente mapa sera necesario establecer algunas condiciones en los campos de los datos para clasificarlos en algunas categorias, esto para que al momento de realizar el mapa, se muestren los datos de los municipios en base a las condiciones propuestas en esta linea.
NBI_munic_2 <- dplyr::mutate(NBI_munic_new, poverty = ifelse(MISERIA > 8, "Extrema", ifelse(HACINAMIENTO > 4, "Alta", "Intermedia")))
head(NBI_munic_2)
## Simple feature collection with 6 features and 21 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 1012801 ymin: 1122899 xmax: 1126288 ymax: 1295432
## projected CRS: MAGNA-SIRGAS / Colombia Bogota zone
## DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR MPIO_CRSLC
## 1 68 68001 BUCARAMANGA 1623
## 2 68 68013 AGUADA 1775
## 3 68 68020 ALBANIA Ordenanza 33 de 1919
## 4 68 68051 ARATOCA 1750
## 5 68 68077 BARBOSA Ordenanza 30 del 25 de Abril de 1936
## 6 68 68079 BARICHARA 1799
## MPIO_NAREA MPIO_NANO DPTO_CNMBR Shape_Leng Shape_Area COD_DPTO DEPTO
## 1 152.90497 2017 SANTANDER 0.6922752 0.012513526 68 SANTANDER
## 2 75.23125 2017 SANTANDER 0.4758098 0.006146093 68 SANTANDER
## 3 166.21697 2017 SANTANDER 0.8761299 0.013570466 68 SANTANDER
## 4 169.79155 2017 SANTANDER 0.6746922 0.013882031 68 SANTANDER
## 5 46.66489 2017 SANTANDER 0.2703415 0.003810882 68 SANTANDER
## 6 137.27581 2017 SANTANDER 0.5610888 0.011223345 68 SANTANDER
## COD_MUN MUN NBI MISERIA VIVIENDA SERVICIOS HACINAMIENTO
## 1 001 BUCARAMANGA 5.384333 0.5966459 0.8669802 0.3521033 1.753256
## 2 013 AGUADA 16.070346 1.8192844 0.6670710 1.0309278 3.153426
## 3 020 ALBANIA 15.542788 1.8748110 1.9655277 2.4795888 4.082250
## 4 051 ARATOCA 19.933851 3.6636560 3.4855616 3.8799135 6.551329
## 5 077 BARBOSA 7.985664 1.0577960 1.0717144 0.2018163 2.442674
## 6 079 BARICHARA 10.962885 0.6868313 0.6339982 0.4887069 6.353190
## INASISTENCIA ECONOMIA geometry poverty
## 1 1.3067750 1.796433 POLYGON ((1109708 1291452, ... Intermedia
## 2 1.8192844 11.825349 POLYGON ((1056982 1181842, ... Intermedia
## 3 0.8164500 8.073783 POLYGON ((1037801 1140975, ... Alta
## 4 0.9159140 9.591655 POLYGON ((1121162 1239493, ... Alta
## 5 1.7606736 3.646613 POLYGON ((1053988 1155051, ... Intermedia
## 6 0.7528728 3.420948 POLYGON ((1094668 1236369, ... Alta
##El mapa nos muestra zonas con NBI altos y medios por todo el departamento, sin embargo, los niveles de pobreza son en general altos sin llegar a ser extremos, mostrando que, efectivamente la zona tiene problemas economicas importantes, pero sus niveles no son tan criticos como los de otras zonas del pais
library(sf)
library(cartography)
# set margins
opar <- par(mar = c(0,0,1.2,0))
# Plot the municipalities
plot(st_geometry(NBI_munic_2), col="#f2efe9", border="#b38e43", bg = "#aad3df",
lwd = 0.5)
# Plot symbols with choropleth coloration
propSymbolsTypoLayer(
x = NBI_munic_2,
var = "NBI",
inches = 0.2,
symbols = "circle",
border = "black",
lwd = .5,
legend.var.pos = c(1200000, 1300000),
legend.var.title.txt = "NBI",
var2 = "poverty",
legend.var2.values.order = c("Extrema","Alta","Intermedia"),
col = carto.pal(pal1 = "multi.pal", n1 = 3),
legend.var2.pos = c(1200000, 1200000),
legend.var2.title.txt = "poverty"
)
# layout
layoutLayer(title="NBI Distribution in Antioquia",
author = "Juan Castilla",
sources = "Source: DANE, 2018",
scale = 1, tabtitle = TRUE, frame = TRUE)
# north arrow
north(pos = "topleft")
library(sf)
library(cartography)
# set margins
opar <- par(mar = c(0,0,1.2,0))
# set figure background color
par(bg="grey25")
# plot municipalities
plot(st_geometry(NBI_munic_2), col = "#e4e9de", border = "darkseagreen4",
bg = "grey75", lwd = 0.5)
# plot NBI
choroLayer(
x = NBI_munic_new,
var = "NBI",
method = "geom",
nclass=10,
col = carto.pal(pal1 = "multi.pal", n1 = 10),
border = "white",
lwd = 0.5,
legend.pos = "topright",
legend.title.txt = "NBI",
add = TRUE
)
# plot labels
labelLayer(
x = NBI_munic_2,
txt = "MUN",
col= "white",
cex = 0.4,
font = 4,
halo = TRUE,
bg = "grey25",
r = 0.1,
overlap = FALSE,
show.lines = FALSE
)
# map layout
layoutLayer(
title = "Municipios de Santander",
sources = "Source: DANE, 2018",
author = "Juan Castilla",
frame = TRUE,
north = TRUE,
tabtitle = TRUE,
theme = "taupe.pal"
)
###ahora tambien se consideraran los datos de evaluaciones agropecuarias del departamento
cultivos2018 <- read_excel("./Evaluaciones_Agropecuarias_Municipales_EVA.xlsx")
cultivos2018
## # A tibble: 14,672 x 17
## COD_DPTO DEPARTAMENTO COD_MUN MUN GRU_CUL SUBGRU_CUL CULT SIST_PROD AÑO
## <dbl> <chr> <dbl> <chr> <chr> <chr> <chr> <chr> <dbl>
## 1 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2007
## 2 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2008
## 3 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2009
## 4 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2010
## 5 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2011
## 6 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2012
## 7 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2013
## 8 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2014
## 9 68 SANTANDER 68013 AGUA~ TUBERC~ ARRACACHA ARRA~ ARRACACHA 2015
## 10 68 SANTANDER 68013 AGUA~ LEGUMI~ ARVEJA ARVE~ ARVEJA 2006
## # ... with 14,662 more rows, and 8 more variables: PERIODO <chr>,
## # AREA_SEM <dbl>, AREA_COS <dbl>, PROD <dbl>, REND <dbl>, ESTADO <chr>,
## # NOMB_CIENTIFICO <chr>, CICLO_CULT <chr>
cultivos2018 %>%
filter(CULT == "CACAO") -> cacao2018
cacao2018$TEMP <- as.character(cacao2018$COD_MUN)
cacao2018$MPIO_CCDGO <- as.factor(cacao2018$TEMP)
cacao2018
## # A tibble: 476 x 19
## COD_DPTO DEPARTAMENTO COD_MUN MUN GRU_CUL SUBGRU_CUL CULT SIST_PROD AÑO
## <dbl> <chr> <dbl> <chr> <chr> <chr> <chr> <chr> <dbl>
## 1 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2007
## 2 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2008
## 3 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2009
## 4 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2010
## 5 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2011
## 6 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2012
## 7 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2013
## 8 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2014
## 9 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2015
## 10 68 SANTANDER 68081 BARR~ OTROS ~ CACAO CACAO CACAO 2016
## # ... with 466 more rows, and 10 more variables: PERIODO <chr>, AREA_SEM <dbl>,
## # AREA_COS <dbl>, PROD <dbl>, REND <dbl>, ESTADO <chr>,
## # NOMB_CIENTIFICO <chr>, CICLO_CULT <chr>, TEMP <chr>, MPIO_CCDGO <fct>
cacao_MUN = left_join(munic, cacao2018, by="MPIO_CCDGO")
## Warning: Column `MPIO_CCDGO` joining character vector and factor, coercing into
## character vector
head(cacao_MUN)
## Simple feature collection with 6 features and 27 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -73.1722 ymin: 7.067471 xmax: -73.04661 ymax: 7.266616
## geographic CRS: WGS 84
## DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR MPIO_CRSLC MPIO_NAREA MPIO_NANO DPTO_CNMBR
## 1 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## 2 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## 3 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## 4 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## 5 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## 6 68 68001 BUCARAMANGA 1623 152.905 2017 SANTANDER
## Shape_Leng Shape_Area COD_DPTO DEPARTAMENTO COD_MUN MUN
## 1 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## 2 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## 3 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## 4 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## 5 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## 6 0.6922752 0.01251353 68 SANTANDER 68001 BUCARAMANGA
## GRU_CUL SUBGRU_CUL CULT SIST_PROD AÑO PERIODO AREA_SEM AREA_COS
## 1 OTROS PERMANENTES CACAO CACAO CACAO 2007 2007 59 30
## 2 OTROS PERMANENTES CACAO CACAO CACAO 2008 2008 16 12
## 3 OTROS PERMANENTES CACAO CACAO CACAO 2009 2009 19 13
## 4 OTROS PERMANENTES CACAO CACAO CACAO 2010 2010 17 10
## 5 OTROS PERMANENTES CACAO CACAO CACAO 2011 2011 17 9
## 6 OTROS PERMANENTES CACAO CACAO CACAO 2012 2012 18 10
## PROD REND ESTADO NOMB_CIENTIFICO CICLO_CULT TEMP
## 1 18 6 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## 2 6 53 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## 3 7 5 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## 4 10 1 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## 5 9 1 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## 6 10 1 GRANO SECO THEOBROMA CACAO PERMANENTE 68001
## geometry
## 1 POLYGON ((-73.08418 7.23063...
## 2 POLYGON ((-73.08418 7.23063...
## 3 POLYGON ((-73.08418 7.23063...
## 4 POLYGON ((-73.08418 7.23063...
## 5 POLYGON ((-73.08418 7.23063...
## 6 POLYGON ((-73.08418 7.23063...
repre_cacao <- st_transform(cacao_MUN, crs = 3116)
# set margins
opar <- par(mar = c(0,0,1.2,0))
# plot municipalities (only the backgroung color is plotted)
plot(st_geometry(repre_cacao), col = NA, border = "black", bg = "grey75")
# plot isopleth map
smoothLayer(
x = repre_cacao,
var = 'PROD',
typefct = "exponential",
span = 30000,
beta = 2,
nclass = 10,
col = carto.pal(pal1 = 'brown.pal', n1 = 10),
border = "grey",
lwd = 0.1,
mask = repre_cacao,
legend.values.rnd = 3,
legend.title.txt = "Production",
legend.pos = "topright",
add=TRUE
)
# annotation on the map
text(x = 870000, y = 1200000, cex = 0.6, adj = 0, font = 3, labels =
"Distance function:\n- type = exponential\n- beta = 2\n- span = 20 km")
# layout
layoutLayer(title = "Cacao Production Distribution in Santander",
sources = "Sources: DANE and MADR, 2018",
author = "Juan Castilla",
frame = TRUE, north = FALSE, tabtitle = TRUE, theme = "green.pal")
# north arrow
north(pos = "topleft")
### El ultimo mapa incluye simbolos para dos variables, y etiquetas para los municipios, lo unico es que dicho mapa se guardara en una imagen png, y luego sera expuesto para la vista del usuario. Las dos variables a analizar seran la produccion de cacao y el rendimiento en ton/ha en el año 2018, esto nos permitira ver que municipios son los encargados de la produccion del fruto en el departamento
### open the plot
png("./cacao_2018.png", width = 2048, height = 1526)
# set margins/
opar <- par(mar = c(0,0,5,5))
# Plot the municipalities
plot(st_geometry(repre_cacao), col="darkseagreen3", border="darkseagreen4",
bg = "white", lwd = 0.6)
# Plot symbols with choropleth coloration
propSymbolsChoroLayer(x = repre_cacao, var = "PROD", var2 = "REND",
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 = "Cacao Production in 2018",
legend.var.style = "e")
# plot labels
labelLayer(
x = NBI_munic_2,
txt = "MPIO_CNMBR",
col= "white",
cex = 1.0,
font = 4,
halo = FALSE,
bg = "white",
r = 0.1,
overlap = FALSE,
show.lines = FALSE
)
# layout
layoutLayer(title="Cacao Production & Yield in Santander, 2018",
author = "Juan Castilla",
sources = "Sources: MADR & DANE, 2018",
scale = 50, tabtitle = FALSE, frame = TRUE)
# north arrow
north(pos = "topleft")
#
title(main="Cacao Production & Yield in Santander, 2018", cex.main=3,
sub= "Source: MADR & DANE, 2018", cex.sub=2)
#
graticule = TRUE
#
par(opar)
### close the plot
dev.off()
## png
## 2
Caption for the picture.