1. Introduccion

Hola yo soy Luis Alberto y este es mi primer R notebook donde manejare funciones basicas como las bibliotecas “simple features” (sf) y “tidyverse” (tidyverse). Tiene como proposito responder a la actividad de aprendizaje de las funcionalidades geoespaciales R en la clase de geomática básica.

para empezar toca instalar y llamar las siguientes librerias.

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(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1

Funciones para buscar archivos y saber la direccion del archivo selecionado.

getwd()
## [1] "D:/Users/Janus/Documents/Geomatica basica"
list.files()
##  [1] "18_CAQUETA"             "Caqueta-R.Rmd"          "Caqueta R.nb.html"     
##  [4] "Caqueta R.Rmd"          "caqueta_municipios.pdf" "COL_adm"               
##  [7] "COL_adm.zip"            "COL_adm0.cpg"           "COL_adm0.csv"          
## [10] "COL_adm0.dbf"           "COL_adm0.prj"           "COL_adm0.shp"          
## [13] "COL_adm0.shx"           "COL_adm1.cpg"           "COL_adm1.csv"          
## [16] "COL_adm1.dbf"           "COL_adm1.prj"           "COL_adm1.shp"          
## [19] "COL_adm1.shx"           "COL_adm2.cpg"           "COL_adm2.csv"          
## [22] "COL_adm2.dbf"           "COL_adm2.prj"           "COL_adm2.shp"          
## [25] "COL_adm2.shx"           "license.txt"            "map_antioquia.png"
list.files("Geomatica basica")
## character(0)

#2. En este paso creamos un vector, en este caso nuestro vector es la direccion del arvico escojido.

deptos<- read_sf("D:/Users/Janus/Documents/Geomatica basica/COL_adm1.shp")

Esta funcion de “head” la utilizamos para saber el contenido del vector

head(deptos)

La funcion “st_crs()” la utilizamos para conocer cual es el sistema de referencia de coordenadas de los datos vectoriales almacenados en el vector “deptos”

st_crs(deptos)
## Coordinate Reference System:
##   User input: WGS 84 
##   wkt:
## GEOGCRS["WGS 84",
##     DATUM["World Geodetic System 1984",
##         ELLIPSOID["WGS 84",6378137,298.257223563,
##             LENGTHUNIT["metre",1]]],
##     PRIMEM["Greenwich",0,
##         ANGLEUNIT["degree",0.0174532925199433]],
##     CS[ellipsoidal,2],
##         AXIS["latitude",north,
##             ORDER[1],
##             ANGLEUNIT["degree",0.0174532925199433]],
##         AXIS["longitude",east,
##             ORDER[2],
##             ANGLEUNIT["degree",0.0174532925199433]],
##     ID["EPSG",4326]]

#3. Visualizar datos geoespaciales usando ggplot:

ggplot() + geom_sf(data = deptos)

Sepuede utilizar cualquier sistema de referencias de coordenadas para trazar datos, en el caso de CRS 3978 es el sistema de referencia de coordenadas usado en canada

ggplot() + geom_sf(data = deptos) + coord_sf(crs = st_crs(3978))

las propiedades del CRS con el código EPSG 32618. Corresponde a UTM 18 N. Por lo cual, en caso de requerir usar dicho CRS, es necesario convertir el objeto espacial de EPSG4326 a EPSG: 32618.Para ello realizamos lo siguiente

deptos_utm <- st_transform(deptos, crs = st_crs(32618))
deptos_utm
ggplot() + geom_sf(data = deptos_utm)

#4. Filtrar los datos geoespaciales basados en atributos como solo nos interesa el departamento de caqueta

caqueta <- deptos %>% filter(NAME_1 == "Caquetá")

trazamos el nuevo vector

ggplot() + geom_sf(data = caqueta)

Vamos a cargar los municipios colombianos y filtrar los del departamento de cacqueta

munic <- read_sf("D:/Users/Janus/Documents/Geomatica basica/COL_adm2.shp")
mun_caqueta <- munic %>% filter(NAME_1 == "Caquetá")
ggplot() + geom_sf(data = mun_caqueta)

mun_caqueta

Vamos a asignar un centroide acada poligono que representan a los municipios de Caqueta para poder ponerles una etiqueta de ID a los municipios.

caqueta_points<- st_centroid(mun_caqueta)
## Warning in st_centroid.sf(mun_caqueta): st_centroid assumes attributes are
## constant over geometries of x
## Warning in st_centroid.sfc(st_geometry(x), of_largest_polygon =
## of_largest_polygon): st_centroid does not give correct centroids for longitude/
## latitude data
caqueta_points <- cbind(mun_caqueta,st_coordinates(st_centroid(mun_caqueta$geometry)))
## Warning in st_centroid.sfc(mun_caqueta$geometry): st_centroid does not give
## correct centroids for longitude/latitude data
ggplot(caqueta) +
  geom_sf(data=deptos) +
  geom_sf(data = caqueta_points, fill = "antiquewhite",) +
  geom_text(data = caqueta_points, aes(x=X, y=Y,label = ID_2), size = 2,) +
  coord_sf(xlim = c(-76.6, -70), ylim = c(-1, 3), expand = FALSE)

library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
ggplot(caqueta) +
  geom_sf(data=caqueta_points, aes(x=X, y=Y, fill =ID_2), color = "black", size = 0.25) + geom_text(data = caqueta_points, aes(x=X, y=Y,label = ID_2), size = 2) +
  theme(aspect.ratio=1)+
  scale_fill_distiller(name="ID_2", palette = "YlOrBr", breaks = pretty_breaks(n =4))+labs(title="Municipios del departamento de Caqueta")
## Warning: Ignoring unknown aesthetics: x, y

Podemos guadar nuestro proceso hasta el momento en PDF

ggsave("caqueta_municipios.pdf")
## Saving 7 x 5 in image
ggsave("map_antioquia.png", width = 6, height = 6, dpi = "screen")

#5. Usamos “leaflt” para visualizar datos para esto necesitamos instalar libreria y llamarla

library(leaflet)

Necesitamos convertir de caracteristicas simples a puntos espaciales

caq_ponits <- as(caqueta_points, "Spatial")

Despues observamos que hay dentro del objeto

head(caq_ponits)
## An object of class "SpatialPolygonsDataFrame"
## Slot "data":
##   ID_0 ISO   NAME_0 ID_1  NAME_1 ID_2                 NAME_2    TYPE_2
## 1   53 COL Colombia    9 Caquetá  373                Albania Municipio
## 2   53 COL Colombia    9 Caquetá  374 Belén de los Andaquies Municipio
## 3   53 COL Colombia    9 Caquetá  375   Cartagena del Chairá Municipio
## 4   53 COL Colombia    9 Caquetá  376                Curillo Municipio
## 5   53 COL Colombia    9 Caquetá  377            El Doncello Municipio
## 6   53 COL Colombia    9 Caquetá  378              El Paujíl Municipio
##      ENGTYPE_2 NL_NAME_2 VARNAME_2         X         Y
## 1 Municipality      <NA>      <NA> -75.95366 1.2632443
## 2 Municipality      <NA>      <NA> -75.93258 1.4601297
## 3 Municipality      <NA>      <NA> -74.60589 0.8524552
## 4 Municipality      <NA>      <NA> -76.03040 1.0986005
## 5 Municipality      <NA>      <NA> -75.28588 1.7086146
## 6 Municipality      <NA>      <NA> -75.41794 1.5310315
## 
## Slot "polygons":
## [[1]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.953662   1.263244
## 
## Slot "area":
## [1] 0.02628928
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.8431 1.278100
##  [2,] -75.8442 1.269400
##  [3,] -75.8477 1.253200
##  [4,] -75.8517 1.238201
##  [5,] -75.8563 1.227899
##  [6,] -75.8603 1.219799
##  [7,] -75.8719 1.208900
##  [8,] -75.8851 1.206001
##  [9,] -75.8972 1.206099
## [10,] -75.9053 1.202100
## [11,] -75.9116 1.191700
## [12,] -75.9197 1.181900
## [13,] -75.9295 1.173900
## [14,] -75.9410 1.165800
## [15,] -75.9600 1.153201
## [16,] -75.9819 1.153301
## [17,] -75.9992 1.162600
## [18,] -76.0010 1.180500
## [19,] -76.0039 1.211200
## [20,] -76.0131 1.223300
## [21,] -76.0252 1.234901
## [22,] -76.0367 1.238402
## [23,] -76.0339 1.253501
## [24,] -76.0321 1.267900
## [25,] -76.0322 1.276000
## [26,] -76.0322 1.290999
## [27,] -76.0304 1.304800
## [28,] -76.0270 1.325000
## [29,] -76.0230 1.338301
## [30,] -76.0178 1.358501
## [31,] -75.9970 1.372301
## [32,] -75.9682 1.374500
## [33,] -75.9561 1.368100
## [34,] -75.9394 1.351301
## [35,] -75.9319 1.338501
## [36,] -75.9152 1.322800
## [37,] -75.9036 1.308900
## [38,] -75.8875 1.293801
## [39,] -75.8771 1.280499
## [40,] -75.8633 1.275301
## [41,] -75.8431 1.278100
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.953662   1.263244
## 
## Slot "ID":
## [1] "1"
## 
## Slot "area":
## [1] 0.02628928
## 
## 
## [[2]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.93258   1.46013
## 
## Slot "area":
## [1] 0.07601064
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##            [,1]     [,2]
##  [1,] -76.01780 1.358501
##  [2,] -76.02930 1.359699
##  [3,] -76.06280 1.363900
##  [4,] -76.08980 1.357101
##  [5,] -76.10660 1.387801
##  [6,] -76.12100 1.419600
##  [7,] -76.12330 1.451400
##  [8,] -76.12510 1.473301
##  [9,] -76.13251 1.493471
## [10,] -76.11930 1.497601
## [11,] -76.11700 1.497601
## [12,] -76.10840 1.501001
## [13,] -76.09740 1.503301
## [14,] -76.07900 1.509500
## [15,] -76.06750 1.512399
## [16,] -76.03810 1.521500
## [17,] -76.02190 1.526601
## [18,] -76.00690 1.541000
## [19,] -75.99600 1.554201
## [20,] -75.97930 1.572101
## [21,] -75.96950 1.588201
## [22,] -75.95970 1.599100
## [23,] -75.94010 1.611801
## [24,] -75.92860 1.623801
## [25,] -75.91480 1.633000
## [26,] -75.89980 1.643399
## [27,] -75.89230 1.648500
## [28,] -75.88080 1.652500
## [29,] -75.86810 1.660600
## [30,] -75.87040 1.670400
## [31,] -75.86520 1.676100
## [32,] -75.85940 1.684800
## [33,] -75.85540 1.692900
## [34,] -75.85310 1.699200
## [35,] -75.84330 1.720500
## [36,] -75.83700 1.736101
## [37,] -75.83184 1.746188
## [38,] -75.83120 1.724500
## [39,] -75.83350 1.697401
## [40,] -75.83350 1.667900
## [41,] -75.83120 1.638499
## [42,] -75.82890 1.613600
## [43,] -75.82890 1.603350
## [44,] -75.83750 1.587700
## [45,] -75.84550 1.562800
## [46,] -75.84610 1.536301
## [47,] -75.83340 1.510200
## [48,] -75.82760 1.477900
## [49,] -75.81780 1.459899
## [50,] -75.80860 1.432700
## [51,] -75.80280 1.411901
## [52,] -75.79300 1.384699
## [53,] -75.79010 1.372599
## [54,] -75.79240 1.363900
## [55,] -75.79870 1.347201
## [56,] -75.79930 1.341400
## [57,] -75.79810 1.322401
## [58,] -75.79120 1.302701
## [59,] -75.78890 1.285299
## [60,] -75.79520 1.272101
## [61,] -75.81250 1.269899
## [62,] -75.82920 1.269300
## [63,] -75.84310 1.278100
## [64,] -75.86330 1.275301
## [65,] -75.87710 1.280499
## [66,] -75.88750 1.293801
## [67,] -75.90360 1.308900
## [68,] -75.91520 1.322800
## [69,] -75.93190 1.338501
## [70,] -75.93940 1.351301
## [71,] -75.95610 1.368100
## [72,] -75.96820 1.374500
## [73,] -75.99700 1.372301
## [74,] -76.01780 1.358501
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.93258   1.46013
## 
## Slot "ID":
## [1] "2"
## 
## Slot "area":
## [1] 0.07601064
## 
## 
## [[3]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -74.6058862   0.8524552
## 
## Slot "area":
## [1] 0.7184032
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##            [,1]     [,2]
##   [1,] -74.9197 1.421500
##   [2,] -74.9024 1.391400
##   [3,] -74.8822 1.361801
##   [4,] -74.8585 1.330000
##   [5,] -74.8291 1.298701
##   [6,] -74.8020 1.285299
##   [7,] -74.7645 1.245800
##   [8,] -74.7426 1.212201
##   [9,] -74.7040 1.190100
##  [10,] -74.6890 1.180202
##  [11,] -74.6693 1.155300
##  [12,] -74.6515 1.136201
##  [13,] -74.6111 1.111201
##  [14,] -74.5921 1.077599
##  [15,] -74.5592 1.053201
##  [16,] -74.5113 1.037999
##  [17,] -74.4704 1.022800
##  [18,] -74.4583 1.004200
##  [19,] -74.4433 0.969500
##  [20,] -74.4219 0.922101
##  [21,] -74.4098 0.891401
##  [22,] -74.3856 0.871700
##  [23,] -74.3371 0.839701
##  [24,] -74.2956 0.813500
##  [25,] -74.2443 0.791901
##  [26,] -74.2224 0.787201
##  [27,] -74.1463 0.801899
##  [28,] -74.1232 0.786800
##  [29,] -74.1169 0.774700
##  [30,] -74.1111 0.764799
##  [31,] -74.0713 0.750801
##  [32,] -74.0483 0.758801
##  [33,] -74.0160 0.755200
##  [34,] -73.9901 0.755099
##  [35,] -73.9756 0.749201
##  [36,] -73.9589 0.739900
##  [37,] -73.9399 0.726601
##  [38,] -73.9180 0.713200
##  [39,] -73.8868 0.702100
##  [40,] -73.8626 0.662701
##  [41,] -73.8453 0.655700
##  [42,] -73.8171 0.640500
##  [43,] -73.7969 0.636999
##  [44,] -73.7675 0.634000
##  [45,] -73.7283 0.633799
##  [46,] -73.7018 0.622201
##  [47,] -73.6833 0.607601
##  [48,] -73.6591 0.604699
##  [49,] -73.6377 0.571599
##  [50,] -73.6331 0.532300
##  [51,] -73.6279 0.500000
##  [52,] -73.6867 0.491599
##  [53,] -73.7299 0.473799
##  [54,] -73.7697 0.457800
##  [55,] -73.7956 0.453301
##  [56,] -73.8360 0.460400
##  [57,] -73.8867 0.476199
##  [58,] -73.9121 0.493101
##  [59,] -73.9559 0.487499
##  [60,] -73.9807 0.467901
##  [61,] -74.0181 0.446201
##  [62,] -74.0475 0.445101
##  [63,] -74.0907 0.426799
##  [64,] -74.1034 0.417600
##  [65,] -74.1317 0.410800
##  [66,] -74.1530 0.432301
##  [67,] -74.1743 0.437000
##  [68,] -74.2078 0.426701
##  [69,] -74.2354 0.429700
##  [70,] -74.2637 0.455300
##  [71,] -74.2885 0.486601
##  [72,] -74.3231 0.505801
##  [73,] -74.3842 0.488700
##  [74,] -74.4199 0.476101
##  [75,] -74.4891 0.464899
##  [76,] -74.5508 0.458800
##  [77,] -74.5531 0.471500
##  [78,] -74.6177 0.476400
##  [79,] -74.6551 0.490401
##  [80,] -74.6990 0.516599
##  [81,] -74.7359 0.528300
##  [82,] -74.7745 0.551600
##  [83,] -74.8298 0.578899
##  [84,] -74.8691 0.594701
##  [85,] -74.9048 0.623201
##  [86,] -74.9210 0.656700
##  [87,] -74.9377 0.700701
##  [88,] -74.9660 0.759701
##  [89,] -74.9919 0.782401
##  [90,] -74.9914 0.825700
##  [91,] -75.0018 0.862700
##  [92,] -75.0433 0.874401
##  [93,] -75.1021 0.886799
##  [94,] -75.1465 0.896800
##  [95,] -75.1949 0.913201
##  [96,] -75.2266 0.923101
##  [97,] -75.2416 0.945100
##  [98,] -75.2445 0.972901
##  [99,] -75.2399 0.997700
## [100,] -75.2284 1.019600
## [101,] -75.2146 1.052502
## [102,] -75.2140 1.072699
## [103,] -75.2100 1.103301
## [104,] -75.2020 1.126899
## [105,] -75.1979 1.133801
## [106,] -75.1974 1.154101
## [107,] -75.1997 1.173100
## [108,] -75.2141 1.193999
## [109,] -75.2262 1.210200
## [110,] -75.2389 1.217800
## [111,] -75.2459 1.241501
## [112,] -75.2372 1.255901
## [113,] -75.2297 1.274300
## [114,] -75.2315 1.287100
## [115,] -75.2372 1.298101
## [116,] -75.2488 1.308501
## [117,] -75.2453 1.327001
## [118,] -75.2494 1.343700
## [119,] -75.2603 1.353001
## [120,] -75.2598 1.367501
## [121,] -75.2575 1.387701
## [122,] -75.2575 1.402100
## [123,] -75.2540 1.420600
## [124,] -75.2558 1.429300
## [125,] -75.2373 1.437299
## [126,] -75.2131 1.441801
## [127,] -75.1849 1.434701
## [128,] -75.1532 1.432301
## [129,] -75.1312 1.432800
## [130,] -75.1082 1.433300
## [131,] -75.0765 1.428500
## [132,] -75.0511 1.427201
## [133,] -75.0229 1.427700
## [134,] -74.9756 1.425801
## [135,] -74.9439 1.421001
## [136,] -74.9197 1.421500
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -74.6058862   0.8524552
## 
## Slot "ID":
## [1] "3"
## 
## Slot "area":
## [1] 0.7184032
## 
## 
## [[4]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -76.030399   1.098601
## 
## Slot "area":
## [1] 0.0385349
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.9197 1.181900
##  [2,] -75.9151 1.160501
##  [3,] -75.9145 1.127601
##  [4,] -75.9122 1.109701
##  [5,] -75.9150 1.082600
##  [6,] -75.9190 1.057201
##  [7,] -75.9150 1.025400
##  [8,] -75.9063 0.991799
##  [9,] -75.9017 0.964700
## [10,] -75.9040 0.939801
## [11,] -75.9051 0.929401
## [12,] -75.9092 0.917900
## [13,] -75.9242 0.931299
## [14,] -75.9322 0.949200
## [15,] -75.9455 0.967200
## [16,] -75.9668 0.975900
## [17,] -75.9634 0.986901
## [18,] -75.9432 0.988501
## [19,] -75.9369 0.994801
## [20,] -75.9444 1.003001
## [21,] -75.9392 1.009301
## [22,] -75.9530 1.019201
## [23,] -75.9628 1.019201
## [24,] -75.9697 1.020400
## [25,] -75.9790 1.033099
## [26,] -75.9871 1.038401
## [27,] -75.9980 1.046501
## [28,] -76.0044 1.054601
## [29,] -76.0101 1.052900
## [30,] -76.0130 1.043100
## [31,] -76.0061 1.034401
## [32,] -76.0038 1.027499
## [33,] -76.0136 1.029801
## [34,] -76.0245 1.039700
## [35,] -76.0430 1.039201
## [36,] -76.0545 1.039201
## [37,] -76.0666 1.037601
## [38,] -76.0793 1.037601
## [39,] -76.0891 1.037701
## [40,] -76.1035 1.046400
## [41,] -76.1116 1.044101
## [42,] -76.1121 1.049299
## [43,] -76.1179 1.056301
## [44,] -76.1237 1.070101
## [45,] -76.1352 1.078901
## [46,] -76.1537 1.092200
## [47,] -76.1658 1.105601
## [48,] -76.1727 1.114799
## [49,] -76.1779 1.103301
## [50,] -76.1917 1.097601
## [51,] -76.2033 1.096500
## [52,] -76.2159 1.098800
## [53,] -76.2171 1.105799
## [54,] -76.2136 1.119000
## [55,] -76.2142 1.131200
## [56,] -76.2096 1.142701
## [57,] -76.2033 1.151300
## [58,] -76.2056 1.163500
## [59,] -76.1837 1.156501
## [60,] -76.1704 1.162201
## [61,] -76.1405 1.166101
## [62,] -76.1122 1.164200
## [63,] -76.0909 1.159500
## [64,] -76.0655 1.151300
## [65,] -76.0505 1.149499
## [66,] -76.0488 1.169800
## [67,] -76.0482 1.181900
## [68,] -76.0471 1.197500
## [69,] -76.0436 1.221101
## [70,] -76.0367 1.238402
## [71,] -76.0252 1.234901
## [72,] -76.0131 1.223300
## [73,] -76.0039 1.211200
## [74,] -76.0010 1.180500
## [75,] -75.9992 1.162600
## [76,] -75.9819 1.153301
## [77,] -75.9600 1.153201
## [78,] -75.9410 1.165800
## [79,] -75.9295 1.173900
## [80,] -75.9197 1.181900
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -76.030399   1.098601
## 
## Slot "ID":
## [1] "4"
## 
## Slot "area":
## [1] 0.0385349
## 
## 
## [[5]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.285882   1.708615
## 
## Slot "area":
## [1] 0.1410316
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.2558 1.429300
##  [2,] -75.2702 1.410301
##  [3,] -75.2967 1.402900
##  [4,] -75.3215 1.406401
##  [5,] -75.3341 1.418000
##  [6,] -75.3515 1.444100
##  [7,] -75.3711 1.477699
##  [8,] -75.3832 1.505500
##  [9,] -75.3959 1.539601
## [10,] -75.4017 1.562700
## [11,] -75.4109 1.598601
## [12,] -75.4133 1.641300
## [13,] -75.4058 1.673600
## [14,] -75.3995 1.708799
## [15,] -75.3995 1.737701
## [16,] -75.4041 1.768900
## [17,] -75.4030 1.822701
## [18,] -75.3967 1.848601
## [19,] -75.3961 1.861301
## [20,] -75.3984 1.876901
## [21,] -75.4013 1.893701
## [22,] -75.4036 1.917399
## [23,] -75.4111 1.946901
## [24,] -75.4157 1.967700
## [25,] -75.4204 1.990200
## [26,] -75.4250 2.015101
## [27,] -75.4417 2.029601
## [28,] -75.4435 2.046900
## [29,] -75.4521 2.067200
## [30,] -75.4602 2.091500
## [31,] -75.4833 2.127401
## [32,] -75.4879 2.149399
## [33,] -75.4896 2.157499
## [34,] -75.4879 2.159200
## [35,] -75.4839 2.163200
## [36,] -75.4821 2.167300
## [37,] -75.4781 2.175901
## [38,] -75.4724 2.182800
## [39,] -75.4683 2.190900
## [40,] -75.4574 2.198900
## [41,] -75.4476 2.209300
## [42,] -75.4349 2.226500
## [43,] -75.4338 2.230001
## [44,] -75.4326 2.232301
## [45,] -75.4251 2.240401
## [46,] -75.4188 2.246700
## [47,] -75.4055 2.259299
## [48,] -75.3905 2.250000
## [49,] -75.3825 2.218200
## [50,] -75.3773 2.204400
## [51,] -75.3680 2.184701
## [52,] -75.3617 2.147699
## [53,] -75.3547 2.100899
## [54,] -75.3449 2.069600
## [55,] -75.3432 2.050000
## [56,] -75.3431 2.030900
## [57,] -75.3379 2.003801
## [58,] -75.3327 1.978900
## [59,] -75.3293 1.946499
## [60,] -75.3241 1.914199
## [61,] -75.3229 1.883500
## [62,] -75.3194 1.858700
## [63,] -75.3188 1.844301
## [64,] -75.2969 1.800300
## [65,] -75.2836 1.772501
## [66,] -75.2761 1.756900
## [67,] -75.2657 1.740101
## [68,] -75.2588 1.724400
## [69,] -75.2530 1.709401
## [70,] -75.2404 1.704100
## [71,] -75.2179 1.696000
## [72,] -75.1988 1.693000
## [73,] -75.1746 1.687100
## [74,] -75.1469 1.664500
## [75,] -75.1221 1.634901
## [76,] -75.1014 1.613401
## [77,] -75.0818 1.589101
## [78,] -75.0702 1.555001
## [79,] -75.0460 1.527701
## [80,] -75.0362 1.504600
## [81,] -75.0304 1.467601
## [82,] -75.0114 1.447300
## [83,] -74.9756 1.448301
## [84,] -74.9445 1.442400
## [85,] -74.9341 1.436600
## [86,] -74.9197 1.421500
## [87,] -74.9439 1.421001
## [88,] -74.9756 1.425801
## [89,] -75.0229 1.427700
## [90,] -75.0511 1.427201
## [91,] -75.0765 1.428500
## [92,] -75.1082 1.433300
## [93,] -75.1312 1.432800
## [94,] -75.1532 1.432301
## [95,] -75.1849 1.434701
## [96,] -75.2131 1.441801
## [97,] -75.2373 1.437299
## [98,] -75.2558 1.429300
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.285882   1.708615
## 
## Slot "ID":
## [1] "5"
## 
## Slot "area":
## [1] 0.1410316
## 
## 
## [[6]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.417937   1.531032
## 
## Slot "area":
## [1] 0.058618
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.2453 1.327001
##  [2,] -75.2626 1.335101
##  [3,] -75.2765 1.334000
##  [4,] -75.2972 1.329501
##  [5,] -75.3266 1.325000
##  [6,] -75.3347 1.307701
##  [7,] -75.3496 1.303099
##  [8,] -75.3635 1.303200
##  [9,] -75.3814 1.311901
## [10,] -75.4021 1.325900
## [11,] -75.4212 1.346200
## [12,] -75.4431 1.369399
## [13,] -75.4817 1.404801
## [14,] -75.4910 1.430200
## [15,] -75.4915 1.446999
## [16,] -75.4916 1.473599
## [17,] -75.4910 1.503600
## [18,] -75.4962 1.544601
## [19,] -75.4991 1.576400
## [20,] -75.5060 1.614600
## [21,] -75.5061 1.656199
## [22,] -75.5020 1.685600
## [23,] -75.5061 1.704701
## [24,] -75.5136 1.730100
## [25,] -75.5096 1.749701
## [26,] -75.5056 1.767601
## [27,] -75.4773 1.794700
## [28,] -75.4462 1.805501
## [29,] -75.4214 1.809400
## [30,] -75.4030 1.822701
## [31,] -75.4041 1.768900
## [32,] -75.3995 1.737701
## [33,] -75.3995 1.708799
## [34,] -75.4058 1.673600
## [35,] -75.4133 1.641300
## [36,] -75.4109 1.598601
## [37,] -75.4017 1.562700
## [38,] -75.3959 1.539601
## [39,] -75.3832 1.505500
## [40,] -75.3711 1.477699
## [41,] -75.3515 1.444100
## [42,] -75.3341 1.418000
## [43,] -75.3215 1.406401
## [44,] -75.2967 1.402900
## [45,] -75.2702 1.410301
## [46,] -75.2558 1.429300
## [47,] -75.2540 1.420600
## [48,] -75.2575 1.402100
## [49,] -75.2575 1.387701
## [50,] -75.2598 1.367501
## [51,] -75.2603 1.353001
## [52,] -75.2494 1.343700
## [53,] -75.2453 1.327001
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.417937   1.531032
## 
## Slot "ID":
## [1] "6"
## 
## Slot "area":
## [1] 0.058618
## 
## 
## 
## Slot "plotOrder":
## [1] 3 5 2 6 4 1
## 
## Slot "bbox":
##        min        max
## x -76.2171 -73.627899
## y   0.4108   2.259299
## 
## Slot "proj4string":
## CRS arguments: +proj=longlat +datum=WGS84 +no_defs

Para obetner el areas de los municipios instalamos y llamamos las siguientes librerias

library(lwgeom)
## Linking to liblwgeom 3.0.0beta1 r16016, GEOS 3.8.0, PROJ 6.3.1
mun_caqueta$area <- st_area(mun_caqueta)

Creamos un campo paraalmacenar el area en kilometros cuadrados y verificamos la salida

mun_caqueta$km2 <- mun_caqueta$area/(100000)
mun_caqueta$km2
## Units: [m^2]
##  [1]   3235.200   9353.236  88418.345   4742.438  17352.031   7212.803
##  [7]  20239.860   8915.957  11930.877   2233.164  27334.959   8359.698
## [13] 180402.569 496760.412  14926.313
caq_mun <- as(mun_caqueta, 'Spatial')
head(caq_mun)
## An object of class "SpatialPolygonsDataFrame"
## Slot "data":
##   ID_0 ISO   NAME_0 ID_1  NAME_1 ID_2                 NAME_2    TYPE_2
## 1   53 COL Colombia    9 Caquetá  373                Albania Municipio
## 2   53 COL Colombia    9 Caquetá  374 Belén de los Andaquies Municipio
## 3   53 COL Colombia    9 Caquetá  375   Cartagena del Chairá Municipio
## 4   53 COL Colombia    9 Caquetá  376                Curillo Municipio
## 5   53 COL Colombia    9 Caquetá  377            El Doncello Municipio
## 6   53 COL Colombia    9 Caquetá  378              El Paujíl Municipio
##      ENGTYPE_2 NL_NAME_2 VARNAME_2             area             km2
## 1 Municipality      <NA>      <NA>  323519987 [m^2]  3235.200 [m^2]
## 2 Municipality      <NA>      <NA>  935323567 [m^2]  9353.236 [m^2]
## 3 Municipality      <NA>      <NA> 8841834493 [m^2] 88418.345 [m^2]
## 4 Municipality      <NA>      <NA>  474243839 [m^2]  4742.438 [m^2]
## 5 Municipality      <NA>      <NA> 1735203063 [m^2] 17352.031 [m^2]
## 6 Municipality      <NA>      <NA>  721280278 [m^2]  7212.803 [m^2]
## 
## Slot "polygons":
## [[1]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.953662   1.263244
## 
## Slot "area":
## [1] 0.02628928
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.8431 1.278100
##  [2,] -75.8442 1.269400
##  [3,] -75.8477 1.253200
##  [4,] -75.8517 1.238201
##  [5,] -75.8563 1.227899
##  [6,] -75.8603 1.219799
##  [7,] -75.8719 1.208900
##  [8,] -75.8851 1.206001
##  [9,] -75.8972 1.206099
## [10,] -75.9053 1.202100
## [11,] -75.9116 1.191700
## [12,] -75.9197 1.181900
## [13,] -75.9295 1.173900
## [14,] -75.9410 1.165800
## [15,] -75.9600 1.153201
## [16,] -75.9819 1.153301
## [17,] -75.9992 1.162600
## [18,] -76.0010 1.180500
## [19,] -76.0039 1.211200
## [20,] -76.0131 1.223300
## [21,] -76.0252 1.234901
## [22,] -76.0367 1.238402
## [23,] -76.0339 1.253501
## [24,] -76.0321 1.267900
## [25,] -76.0322 1.276000
## [26,] -76.0322 1.290999
## [27,] -76.0304 1.304800
## [28,] -76.0270 1.325000
## [29,] -76.0230 1.338301
## [30,] -76.0178 1.358501
## [31,] -75.9970 1.372301
## [32,] -75.9682 1.374500
## [33,] -75.9561 1.368100
## [34,] -75.9394 1.351301
## [35,] -75.9319 1.338501
## [36,] -75.9152 1.322800
## [37,] -75.9036 1.308900
## [38,] -75.8875 1.293801
## [39,] -75.8771 1.280499
## [40,] -75.8633 1.275301
## [41,] -75.8431 1.278100
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.953662   1.263244
## 
## Slot "ID":
## [1] "1"
## 
## Slot "area":
## [1] 0.02628928
## 
## 
## [[2]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.93258   1.46013
## 
## Slot "area":
## [1] 0.07601064
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##            [,1]     [,2]
##  [1,] -76.01780 1.358501
##  [2,] -76.02930 1.359699
##  [3,] -76.06280 1.363900
##  [4,] -76.08980 1.357101
##  [5,] -76.10660 1.387801
##  [6,] -76.12100 1.419600
##  [7,] -76.12330 1.451400
##  [8,] -76.12510 1.473301
##  [9,] -76.13251 1.493471
## [10,] -76.11930 1.497601
## [11,] -76.11700 1.497601
## [12,] -76.10840 1.501001
## [13,] -76.09740 1.503301
## [14,] -76.07900 1.509500
## [15,] -76.06750 1.512399
## [16,] -76.03810 1.521500
## [17,] -76.02190 1.526601
## [18,] -76.00690 1.541000
## [19,] -75.99600 1.554201
## [20,] -75.97930 1.572101
## [21,] -75.96950 1.588201
## [22,] -75.95970 1.599100
## [23,] -75.94010 1.611801
## [24,] -75.92860 1.623801
## [25,] -75.91480 1.633000
## [26,] -75.89980 1.643399
## [27,] -75.89230 1.648500
## [28,] -75.88080 1.652500
## [29,] -75.86810 1.660600
## [30,] -75.87040 1.670400
## [31,] -75.86520 1.676100
## [32,] -75.85940 1.684800
## [33,] -75.85540 1.692900
## [34,] -75.85310 1.699200
## [35,] -75.84330 1.720500
## [36,] -75.83700 1.736101
## [37,] -75.83184 1.746188
## [38,] -75.83120 1.724500
## [39,] -75.83350 1.697401
## [40,] -75.83350 1.667900
## [41,] -75.83120 1.638499
## [42,] -75.82890 1.613600
## [43,] -75.82890 1.603350
## [44,] -75.83750 1.587700
## [45,] -75.84550 1.562800
## [46,] -75.84610 1.536301
## [47,] -75.83340 1.510200
## [48,] -75.82760 1.477900
## [49,] -75.81780 1.459899
## [50,] -75.80860 1.432700
## [51,] -75.80280 1.411901
## [52,] -75.79300 1.384699
## [53,] -75.79010 1.372599
## [54,] -75.79240 1.363900
## [55,] -75.79870 1.347201
## [56,] -75.79930 1.341400
## [57,] -75.79810 1.322401
## [58,] -75.79120 1.302701
## [59,] -75.78890 1.285299
## [60,] -75.79520 1.272101
## [61,] -75.81250 1.269899
## [62,] -75.82920 1.269300
## [63,] -75.84310 1.278100
## [64,] -75.86330 1.275301
## [65,] -75.87710 1.280499
## [66,] -75.88750 1.293801
## [67,] -75.90360 1.308900
## [68,] -75.91520 1.322800
## [69,] -75.93190 1.338501
## [70,] -75.93940 1.351301
## [71,] -75.95610 1.368100
## [72,] -75.96820 1.374500
## [73,] -75.99700 1.372301
## [74,] -76.01780 1.358501
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.93258   1.46013
## 
## Slot "ID":
## [1] "2"
## 
## Slot "area":
## [1] 0.07601064
## 
## 
## [[3]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -74.6058862   0.8524552
## 
## Slot "area":
## [1] 0.7184032
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##            [,1]     [,2]
##   [1,] -74.9197 1.421500
##   [2,] -74.9024 1.391400
##   [3,] -74.8822 1.361801
##   [4,] -74.8585 1.330000
##   [5,] -74.8291 1.298701
##   [6,] -74.8020 1.285299
##   [7,] -74.7645 1.245800
##   [8,] -74.7426 1.212201
##   [9,] -74.7040 1.190100
##  [10,] -74.6890 1.180202
##  [11,] -74.6693 1.155300
##  [12,] -74.6515 1.136201
##  [13,] -74.6111 1.111201
##  [14,] -74.5921 1.077599
##  [15,] -74.5592 1.053201
##  [16,] -74.5113 1.037999
##  [17,] -74.4704 1.022800
##  [18,] -74.4583 1.004200
##  [19,] -74.4433 0.969500
##  [20,] -74.4219 0.922101
##  [21,] -74.4098 0.891401
##  [22,] -74.3856 0.871700
##  [23,] -74.3371 0.839701
##  [24,] -74.2956 0.813500
##  [25,] -74.2443 0.791901
##  [26,] -74.2224 0.787201
##  [27,] -74.1463 0.801899
##  [28,] -74.1232 0.786800
##  [29,] -74.1169 0.774700
##  [30,] -74.1111 0.764799
##  [31,] -74.0713 0.750801
##  [32,] -74.0483 0.758801
##  [33,] -74.0160 0.755200
##  [34,] -73.9901 0.755099
##  [35,] -73.9756 0.749201
##  [36,] -73.9589 0.739900
##  [37,] -73.9399 0.726601
##  [38,] -73.9180 0.713200
##  [39,] -73.8868 0.702100
##  [40,] -73.8626 0.662701
##  [41,] -73.8453 0.655700
##  [42,] -73.8171 0.640500
##  [43,] -73.7969 0.636999
##  [44,] -73.7675 0.634000
##  [45,] -73.7283 0.633799
##  [46,] -73.7018 0.622201
##  [47,] -73.6833 0.607601
##  [48,] -73.6591 0.604699
##  [49,] -73.6377 0.571599
##  [50,] -73.6331 0.532300
##  [51,] -73.6279 0.500000
##  [52,] -73.6867 0.491599
##  [53,] -73.7299 0.473799
##  [54,] -73.7697 0.457800
##  [55,] -73.7956 0.453301
##  [56,] -73.8360 0.460400
##  [57,] -73.8867 0.476199
##  [58,] -73.9121 0.493101
##  [59,] -73.9559 0.487499
##  [60,] -73.9807 0.467901
##  [61,] -74.0181 0.446201
##  [62,] -74.0475 0.445101
##  [63,] -74.0907 0.426799
##  [64,] -74.1034 0.417600
##  [65,] -74.1317 0.410800
##  [66,] -74.1530 0.432301
##  [67,] -74.1743 0.437000
##  [68,] -74.2078 0.426701
##  [69,] -74.2354 0.429700
##  [70,] -74.2637 0.455300
##  [71,] -74.2885 0.486601
##  [72,] -74.3231 0.505801
##  [73,] -74.3842 0.488700
##  [74,] -74.4199 0.476101
##  [75,] -74.4891 0.464899
##  [76,] -74.5508 0.458800
##  [77,] -74.5531 0.471500
##  [78,] -74.6177 0.476400
##  [79,] -74.6551 0.490401
##  [80,] -74.6990 0.516599
##  [81,] -74.7359 0.528300
##  [82,] -74.7745 0.551600
##  [83,] -74.8298 0.578899
##  [84,] -74.8691 0.594701
##  [85,] -74.9048 0.623201
##  [86,] -74.9210 0.656700
##  [87,] -74.9377 0.700701
##  [88,] -74.9660 0.759701
##  [89,] -74.9919 0.782401
##  [90,] -74.9914 0.825700
##  [91,] -75.0018 0.862700
##  [92,] -75.0433 0.874401
##  [93,] -75.1021 0.886799
##  [94,] -75.1465 0.896800
##  [95,] -75.1949 0.913201
##  [96,] -75.2266 0.923101
##  [97,] -75.2416 0.945100
##  [98,] -75.2445 0.972901
##  [99,] -75.2399 0.997700
## [100,] -75.2284 1.019600
## [101,] -75.2146 1.052502
## [102,] -75.2140 1.072699
## [103,] -75.2100 1.103301
## [104,] -75.2020 1.126899
## [105,] -75.1979 1.133801
## [106,] -75.1974 1.154101
## [107,] -75.1997 1.173100
## [108,] -75.2141 1.193999
## [109,] -75.2262 1.210200
## [110,] -75.2389 1.217800
## [111,] -75.2459 1.241501
## [112,] -75.2372 1.255901
## [113,] -75.2297 1.274300
## [114,] -75.2315 1.287100
## [115,] -75.2372 1.298101
## [116,] -75.2488 1.308501
## [117,] -75.2453 1.327001
## [118,] -75.2494 1.343700
## [119,] -75.2603 1.353001
## [120,] -75.2598 1.367501
## [121,] -75.2575 1.387701
## [122,] -75.2575 1.402100
## [123,] -75.2540 1.420600
## [124,] -75.2558 1.429300
## [125,] -75.2373 1.437299
## [126,] -75.2131 1.441801
## [127,] -75.1849 1.434701
## [128,] -75.1532 1.432301
## [129,] -75.1312 1.432800
## [130,] -75.1082 1.433300
## [131,] -75.0765 1.428500
## [132,] -75.0511 1.427201
## [133,] -75.0229 1.427700
## [134,] -74.9756 1.425801
## [135,] -74.9439 1.421001
## [136,] -74.9197 1.421500
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -74.6058862   0.8524552
## 
## Slot "ID":
## [1] "3"
## 
## Slot "area":
## [1] 0.7184032
## 
## 
## [[4]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -76.030399   1.098601
## 
## Slot "area":
## [1] 0.0385349
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.9197 1.181900
##  [2,] -75.9151 1.160501
##  [3,] -75.9145 1.127601
##  [4,] -75.9122 1.109701
##  [5,] -75.9150 1.082600
##  [6,] -75.9190 1.057201
##  [7,] -75.9150 1.025400
##  [8,] -75.9063 0.991799
##  [9,] -75.9017 0.964700
## [10,] -75.9040 0.939801
## [11,] -75.9051 0.929401
## [12,] -75.9092 0.917900
## [13,] -75.9242 0.931299
## [14,] -75.9322 0.949200
## [15,] -75.9455 0.967200
## [16,] -75.9668 0.975900
## [17,] -75.9634 0.986901
## [18,] -75.9432 0.988501
## [19,] -75.9369 0.994801
## [20,] -75.9444 1.003001
## [21,] -75.9392 1.009301
## [22,] -75.9530 1.019201
## [23,] -75.9628 1.019201
## [24,] -75.9697 1.020400
## [25,] -75.9790 1.033099
## [26,] -75.9871 1.038401
## [27,] -75.9980 1.046501
## [28,] -76.0044 1.054601
## [29,] -76.0101 1.052900
## [30,] -76.0130 1.043100
## [31,] -76.0061 1.034401
## [32,] -76.0038 1.027499
## [33,] -76.0136 1.029801
## [34,] -76.0245 1.039700
## [35,] -76.0430 1.039201
## [36,] -76.0545 1.039201
## [37,] -76.0666 1.037601
## [38,] -76.0793 1.037601
## [39,] -76.0891 1.037701
## [40,] -76.1035 1.046400
## [41,] -76.1116 1.044101
## [42,] -76.1121 1.049299
## [43,] -76.1179 1.056301
## [44,] -76.1237 1.070101
## [45,] -76.1352 1.078901
## [46,] -76.1537 1.092200
## [47,] -76.1658 1.105601
## [48,] -76.1727 1.114799
## [49,] -76.1779 1.103301
## [50,] -76.1917 1.097601
## [51,] -76.2033 1.096500
## [52,] -76.2159 1.098800
## [53,] -76.2171 1.105799
## [54,] -76.2136 1.119000
## [55,] -76.2142 1.131200
## [56,] -76.2096 1.142701
## [57,] -76.2033 1.151300
## [58,] -76.2056 1.163500
## [59,] -76.1837 1.156501
## [60,] -76.1704 1.162201
## [61,] -76.1405 1.166101
## [62,] -76.1122 1.164200
## [63,] -76.0909 1.159500
## [64,] -76.0655 1.151300
## [65,] -76.0505 1.149499
## [66,] -76.0488 1.169800
## [67,] -76.0482 1.181900
## [68,] -76.0471 1.197500
## [69,] -76.0436 1.221101
## [70,] -76.0367 1.238402
## [71,] -76.0252 1.234901
## [72,] -76.0131 1.223300
## [73,] -76.0039 1.211200
## [74,] -76.0010 1.180500
## [75,] -75.9992 1.162600
## [76,] -75.9819 1.153301
## [77,] -75.9600 1.153201
## [78,] -75.9410 1.165800
## [79,] -75.9295 1.173900
## [80,] -75.9197 1.181900
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -76.030399   1.098601
## 
## Slot "ID":
## [1] "4"
## 
## Slot "area":
## [1] 0.0385349
## 
## 
## [[5]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.285882   1.708615
## 
## Slot "area":
## [1] 0.1410316
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.2558 1.429300
##  [2,] -75.2702 1.410301
##  [3,] -75.2967 1.402900
##  [4,] -75.3215 1.406401
##  [5,] -75.3341 1.418000
##  [6,] -75.3515 1.444100
##  [7,] -75.3711 1.477699
##  [8,] -75.3832 1.505500
##  [9,] -75.3959 1.539601
## [10,] -75.4017 1.562700
## [11,] -75.4109 1.598601
## [12,] -75.4133 1.641300
## [13,] -75.4058 1.673600
## [14,] -75.3995 1.708799
## [15,] -75.3995 1.737701
## [16,] -75.4041 1.768900
## [17,] -75.4030 1.822701
## [18,] -75.3967 1.848601
## [19,] -75.3961 1.861301
## [20,] -75.3984 1.876901
## [21,] -75.4013 1.893701
## [22,] -75.4036 1.917399
## [23,] -75.4111 1.946901
## [24,] -75.4157 1.967700
## [25,] -75.4204 1.990200
## [26,] -75.4250 2.015101
## [27,] -75.4417 2.029601
## [28,] -75.4435 2.046900
## [29,] -75.4521 2.067200
## [30,] -75.4602 2.091500
## [31,] -75.4833 2.127401
## [32,] -75.4879 2.149399
## [33,] -75.4896 2.157499
## [34,] -75.4879 2.159200
## [35,] -75.4839 2.163200
## [36,] -75.4821 2.167300
## [37,] -75.4781 2.175901
## [38,] -75.4724 2.182800
## [39,] -75.4683 2.190900
## [40,] -75.4574 2.198900
## [41,] -75.4476 2.209300
## [42,] -75.4349 2.226500
## [43,] -75.4338 2.230001
## [44,] -75.4326 2.232301
## [45,] -75.4251 2.240401
## [46,] -75.4188 2.246700
## [47,] -75.4055 2.259299
## [48,] -75.3905 2.250000
## [49,] -75.3825 2.218200
## [50,] -75.3773 2.204400
## [51,] -75.3680 2.184701
## [52,] -75.3617 2.147699
## [53,] -75.3547 2.100899
## [54,] -75.3449 2.069600
## [55,] -75.3432 2.050000
## [56,] -75.3431 2.030900
## [57,] -75.3379 2.003801
## [58,] -75.3327 1.978900
## [59,] -75.3293 1.946499
## [60,] -75.3241 1.914199
## [61,] -75.3229 1.883500
## [62,] -75.3194 1.858700
## [63,] -75.3188 1.844301
## [64,] -75.2969 1.800300
## [65,] -75.2836 1.772501
## [66,] -75.2761 1.756900
## [67,] -75.2657 1.740101
## [68,] -75.2588 1.724400
## [69,] -75.2530 1.709401
## [70,] -75.2404 1.704100
## [71,] -75.2179 1.696000
## [72,] -75.1988 1.693000
## [73,] -75.1746 1.687100
## [74,] -75.1469 1.664500
## [75,] -75.1221 1.634901
## [76,] -75.1014 1.613401
## [77,] -75.0818 1.589101
## [78,] -75.0702 1.555001
## [79,] -75.0460 1.527701
## [80,] -75.0362 1.504600
## [81,] -75.0304 1.467601
## [82,] -75.0114 1.447300
## [83,] -74.9756 1.448301
## [84,] -74.9445 1.442400
## [85,] -74.9341 1.436600
## [86,] -74.9197 1.421500
## [87,] -74.9439 1.421001
## [88,] -74.9756 1.425801
## [89,] -75.0229 1.427700
## [90,] -75.0511 1.427201
## [91,] -75.0765 1.428500
## [92,] -75.1082 1.433300
## [93,] -75.1312 1.432800
## [94,] -75.1532 1.432301
## [95,] -75.1849 1.434701
## [96,] -75.2131 1.441801
## [97,] -75.2373 1.437299
## [98,] -75.2558 1.429300
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.285882   1.708615
## 
## Slot "ID":
## [1] "5"
## 
## Slot "area":
## [1] 0.1410316
## 
## 
## [[6]]
## An object of class "Polygons"
## Slot "Polygons":
## [[1]]
## An object of class "Polygon"
## Slot "labpt":
## [1] -75.417937   1.531032
## 
## Slot "area":
## [1] 0.058618
## 
## Slot "hole":
## [1] FALSE
## 
## Slot "ringDir":
## [1] 1
## 
## Slot "coords":
##           [,1]     [,2]
##  [1,] -75.2453 1.327001
##  [2,] -75.2626 1.335101
##  [3,] -75.2765 1.334000
##  [4,] -75.2972 1.329501
##  [5,] -75.3266 1.325000
##  [6,] -75.3347 1.307701
##  [7,] -75.3496 1.303099
##  [8,] -75.3635 1.303200
##  [9,] -75.3814 1.311901
## [10,] -75.4021 1.325900
## [11,] -75.4212 1.346200
## [12,] -75.4431 1.369399
## [13,] -75.4817 1.404801
## [14,] -75.4910 1.430200
## [15,] -75.4915 1.446999
## [16,] -75.4916 1.473599
## [17,] -75.4910 1.503600
## [18,] -75.4962 1.544601
## [19,] -75.4991 1.576400
## [20,] -75.5060 1.614600
## [21,] -75.5061 1.656199
## [22,] -75.5020 1.685600
## [23,] -75.5061 1.704701
## [24,] -75.5136 1.730100
## [25,] -75.5096 1.749701
## [26,] -75.5056 1.767601
## [27,] -75.4773 1.794700
## [28,] -75.4462 1.805501
## [29,] -75.4214 1.809400
## [30,] -75.4030 1.822701
## [31,] -75.4041 1.768900
## [32,] -75.3995 1.737701
## [33,] -75.3995 1.708799
## [34,] -75.4058 1.673600
## [35,] -75.4133 1.641300
## [36,] -75.4109 1.598601
## [37,] -75.4017 1.562700
## [38,] -75.3959 1.539601
## [39,] -75.3832 1.505500
## [40,] -75.3711 1.477699
## [41,] -75.3515 1.444100
## [42,] -75.3341 1.418000
## [43,] -75.3215 1.406401
## [44,] -75.2967 1.402900
## [45,] -75.2702 1.410301
## [46,] -75.2558 1.429300
## [47,] -75.2540 1.420600
## [48,] -75.2575 1.402100
## [49,] -75.2575 1.387701
## [50,] -75.2598 1.367501
## [51,] -75.2603 1.353001
## [52,] -75.2494 1.343700
## [53,] -75.2453 1.327001
## 
## 
## 
## Slot "plotOrder":
## [1] 1
## 
## Slot "labpt":
## [1] -75.417937   1.531032
## 
## Slot "ID":
## [1] "6"
## 
## Slot "area":
## [1] 0.058618
## 
## 
## 
## Slot "plotOrder":
## [1] 3 5 2 6 4 1
## 
## Slot "bbox":
##        min        max
## x -76.2171 -73.627899
## y   0.4108   2.259299
## 
## Slot "proj4string":
## CRS arguments: +proj=longlat +datum=WGS84 +no_defs

ahora preparemos el plot

bins <- c(0, 50, 100, 200, 300, 500, 1000, 2000, Inf)
pal <- colorBin("OrRd", domain = caq_mun$km2, bins = bins)

labels <- mun_caqueta$NAME_2

labels
##  [1] "Albania"                "Belén de los Andaquies" "Cartagena del Chairá"  
##  [4] "Curillo"                "El Doncello"            "El Paujíl"             
##  [7] "Florencia"              "La Montañita"           "Milán"                 
## [10] "Morelia"                "Puerto Rico"            "San José del Fragua"   
## [13] "San Vicente del Caguán" "Solano"                 "Valparaíso"

Ha llegado el momento de crear el plot

m <- leaflet(caq_mun) %>% 
  
  addProviderTiles(providers$CartoDB.PositronNoLabels) %>%
   
  setView(-77, 2, 7.4)  %>% addPolygons(
  fillColor = ~pal(km2),
  weight = 2,
  opacity = 1,
  color = "black",
  dashArray = "3",
  fillOpacity = 0.7,
  highlight = highlightOptions(
    weight = 5,
    color = "#666",
    dashArray = "",
    fillOpacity = 0.7,
    bringToFront = TRUE),
  label = labels) %>%
  addLegend(pal = pal, values = ~km2, opacity = 0.7, title = NULL,
    position = "bottomright")
m
NA
## [1] NA

Puede probar diferentes proveedores para mejorar su mapa. Aproveche la función de completar con pestañas para seleccionar el mapa base preferido simplemente desplazándose por la lista de proveedores con addProviderTiles()

cap_caqueta <- munic %>% filter(NAME_2 == "Florencia")
cap_caqueta$area <- st_area(cap_caqueta)
cap_caqueta$km2 <-cap_caqueta$area/(1000000)
cap_caqueta$km2
## Units: [m^2]
## [1] 2023.98600   28.42409

Podemos visualizar el departamento de caqueta en el mundo

caq_cap <- as(cap_caqueta, 'Spatial')
leaflet(caq_mun) %>%
  addProviderTiles(providers$Esri.WorldImagery, options = providerTileOptions(opacity = 0.99)) %>%
  addPolygons(data = caq_mun, popup = caq_mun$NAME_2,
              stroke = TRUE, fillOpacity = 0.25, smoothFactor = 0.25)