Maykol Linares

1. iNTRODUCCIÓN

2. ARREGLOS

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.8
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   2.1.2     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(dplyr)
library(readr)
library(ggplot2)
library(ggrepel)
library(classInt)
library(knitr)
library(rmarkdown)

3. LEYENDO LOS ARCHIVOS DE LOS MUNICIPIOS, CULTIVOS Y CIUDADES

list.files("./DATOS", pattern=c('csv'))
## [1] "cauca_platanos_2020.csv"   "cauca_tropicales_2020.csv"
## [3] "cauca_tuberculos_2020.csv" "co.csv"
list.files("./COLOMBIA-CAUCA")
## [1] "Cauca.pdf"            "Cauca.png"            "COLOMBIA-CAUCA.0.tif"
## [4] "COLOMBIA-CAUCA.vrt"   "DATOS"                "PROYECTOS"
list.files("./COLOMBIA-CAUCA/DATOS", pattern = 'shp')
## [1] "Cauca.shp"             "departamentoCAUCA.shp"
(tropicales = read.csv("./DATOS/cauca_tropicales_2020.csv"))
(mun.tmp = st_read("./COLOMBIA-CAUCA/DATOS/Cauca.shp"))
## Reading layer `Cauca' from data source 
##   `F:\CuadernosR 2\COLOMBIA-CAUCA\DATOS\Cauca.shp' using driver `ESRI Shapefile'
## Simple feature collection with 42 features and 11 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -77.92834 ymin: 0.9580285 xmax: -75.74782 ymax: 3.328941
## Geodetic CRS:  WGS 84
(mun.tmp %>% dplyr::select(MPIO_CCDGO, MPIO_CCNCT, MPIO_NAREA) -> municipios)
municipios
(ciudades= readr::read_csv("./DATOS/co.csv"))
(sfciudades = st_as_sf(x = ciudades, coords = c("lng","lat")))
st_crs(sfciudades) <- 4326

4. SELECCIÓN DE LOS DATOS IMPORTANTES PARA NUESTRO DEPARTAMENTO

(sfciudades.joined <- st_join(sfciudades, municipios, join = st_within))
(cauca.ciudades = filter(sfciudades.joined, admin_name == 'Cauca'))

5. CREANDO EL MAPA PARA EL GRUPO DE CULTIVOS MÁS IMPORTANTES EN EL CAUCA

class(tropicales$Cod_Mun)
## [1] "integer"
class(municipios$MPIO_CCNCT)
## [1] "character"
tropicales$Cod_Mun = as.factor(tropicales$Cod_Mun)
(munic_tropicales = left_join(municipios, tropicales, by = c("MPIO_CCNCT" = "Cod_Mun"), na.rm = TRUE))

``{r}

breaks <- classIntervals(munic_frutales$max_prod, n = 6, style = ‘fisher’)

#label breaks lab_vec <- vector(length = length(breaks\(brks)-1) rounded_breaks <- round(breaks\)brks,2) lab_vec[1] <- paste0(‘[’, rounded_breaks[1],’ - ’, rounded_breaks[2],’]’) for(i in 2:(length(breaks$brks) - 1)){ lab_vec[i] <- paste0(‘(’,rounded_breaks[i], ’ - ‘, rounded_breaks[i+1],’]’) }







```r
munic_tropicales$mid <- sf::st_centroid(munic_tropicales$geometry)
LONG = sf::st_coordinates(munic_tropicales$mid)[,1]
LAT = st_coordinates(munic_tropicales$mid)[,2]
ggplot(data = munic_tropicales) +
   geom_sf(aes(fill = max_prod)) +
   geom_label_repel(aes(x = LONG, y = LAT, label = Municipio), 
                    label.padding =     unit(0.05,"lines"),  
                    label.r = unit(0.025, "lines"),
                    label.size = 0.05) 
## Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps

6.

(platano = read_csv("./DATOS/cauca_platanos_2020.csv"))
## Rows: 36 Columns: 4
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (2): Municipio, Grupo
## dbl (2): Cod_Mun, max_prod
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
municipios
platano$Cod_Mun = as.factor(platano$Cod_Mun)
municipios$MPIO_CCNCT = as.factor(municipios$MPIO_CCNCT)
(munic_platano = left_join(municipios, platano, by = c("MPIO_CCNCT" = "Cod_Mun")))

``{r} facet = “max_prod” oleag_map =
tm_shape(munic_oleag) + tm_polygons(facet) + tm_text(text = “MPIO_CNMBR”, size = 0.7, fontfamily = “sans”) + tm_shape(stder.cities) + tm_symbols(shape = 2, col = “red”, size = 0.20) + tm_credits(“Data source: UPRA (2020)”, fontface = “bold”) + tm_layout(main.title = “Produccion de oleaginosas en 2020”, main.title.fontface = “bold.italic”, legend.title.fontfamily = “monospace”) + tm_scale_bar(position = c(“left”, “bottom”))


```r
#tmap_mode("view")
#oleag_map

grafica de produccion de otros permanentes (2008-2014)

  1. Bibliography In your notebook, cite this work as Lizarazo, I., 2022. Getting started with thematic maps. Available at https://rpubs.com/ials2un/thematic_maps_v2.
sessionInfo()
## R version 4.1.3 (2022-03-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19044)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=Spanish_Colombia.1252  LC_CTYPE=Spanish_Colombia.1252   
## [3] LC_MONETARY=Spanish_Colombia.1252 LC_NUMERIC=C                     
## [5] LC_TIME=Spanish_Colombia.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] rmarkdown_2.13  knitr_1.38      classInt_0.4-3  ggrepel_0.9.1  
##  [5] sf_1.0-7        forcats_0.5.1   stringr_1.4.0   dplyr_1.0.8    
##  [9] purrr_0.3.4     readr_2.1.2     tidyr_1.2.0     tibble_3.1.6   
## [13] ggplot2_3.3.5   tidyverse_1.3.1
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.8.3       lubridate_1.8.0    class_7.3-20       assertthat_0.2.1  
##  [5] digest_0.6.29      utf8_1.2.2         R6_2.5.1           cellranger_1.1.0  
##  [9] backports_1.4.1    reprex_2.0.1       evaluate_0.15      e1071_1.7-9       
## [13] highr_0.9          httr_1.4.2         pillar_1.7.0       rlang_1.0.2       
## [17] readxl_1.3.1       rstudioapi_0.13    jquerylib_0.1.4    labeling_0.4.2    
## [21] bit_4.0.4          munsell_0.5.0      proxy_0.4-26       broom_0.7.12      
## [25] compiler_4.1.3     modelr_0.1.8       xfun_0.30          pkgconfig_2.0.3   
## [29] htmltools_0.5.2    tidyselect_1.1.2   fansi_1.0.3        crayon_1.5.1      
## [33] tzdb_0.3.0         dbplyr_2.1.1       withr_2.5.0        wk_0.6.0          
## [37] grid_4.1.3         jsonlite_1.8.0     gtable_0.3.0       lifecycle_1.0.1   
## [41] DBI_1.1.2          magrittr_2.0.2     units_0.8-0        scales_1.1.1      
## [45] KernSmooth_2.23-20 vroom_1.5.7        cli_3.2.0          stringi_1.7.6     
## [49] farver_2.1.0       fs_1.5.2           xml2_1.3.3         bslib_0.3.1       
## [53] ellipsis_0.3.2     generics_0.1.2     vctrs_0.3.8        s2_1.0.7          
## [57] tools_4.1.3        bit64_4.0.5        glue_1.6.2         hms_1.1.1         
## [61] parallel_4.1.3     fastmap_1.1.0      yaml_2.3.5         colorspace_2.0-3  
## [65] rvest_1.0.2        haven_2.4.3        sass_0.4.1