Marzo 21 de 2020
deptos <- read_sf("./COL_adm1.shp")
head(deptos)
Simple feature collection with 6 features and 9 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -77.149 ymin: -4.228429 xmax: -69.36835 ymax: 11.10792
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
st_crs(deptos)
Coordinate Reference System:
EPSG: 4326
proj4string: "+proj=longlat +datum=WGS84 +no_defs"
ggplot() + geom_sf(data = deptos)

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

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

caquetá <- deptos %>% filter(NAME_1 == "Caquetá")
ggplot() + geom_sf(data = caquetá)

munic <- read_sf("./COL_adm2.shp")
mun_caquetá <- munic %>% filter(NAME_1 == "Caquetá")
ggplot() + geom_sf(data = mun_caquetá)

mun_caquetá
Simple feature collection with 15 features and 11 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -76.3129 ymin: -0.730099 xmax: -71.4769 ymax: 2.9441
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
caquetá_points <- st_centroid (mun_caquetá)
st_centroid assumes attributes are constant over geometries of xst_centroid does not give correct centroids for longitude/latitude data
caquetá_points <- cbind(mun_caquetá,
st_coordinates(st_centroid(mun_caquetá$geometry)))
st_centroid does not give correct centroids for longitude/latitude data
ggplot(caquetá) +
geom_sf() +
geom_sf(data = caquetá_points, fill = "antiquewhite") +
geom_text(data = caquetá_points, aes(x=X, y=Y,label = ID_2), size = 2) +
coord_sf(xlim = c(-76.4, -71.4), ylim = c(-0.8, 3), expand = FALSE)

library(scales)
ggplot(caquetá) +
geom_sf(data=caquetá_points, aes(x=X, y=Y, fill =
ID_2), color = "black", size = 0.25) +
geom_text(data = caquetá_points, aes(x=X, y=Y,label = ID_2), size = 2) +
theme(aspect.ratio=1)+
scale_fill_distiller(name="ID_2", palette = "YlGn", breaks = pretty_breaks(n = 5))+
labs(title="Another Map of caquetá")
Ignoring unknown aesthetics: x, y

ggsave("caquetá_municipios.pdf")
Saving 7 x 7 in image
ggsave("map_caquetá.png", width = 6, height = 6, dpi = "screen")
install.packages("leaflet")
library(leaflet)
ant_points <- as(caquetá_points, 'Spatial')
head(ant_points)
An object of class "SpatialPolygonsDataFrame"
Slot "data":
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
install.packages("lwgeom")
Installing package into ‘/home/rstudio-user/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'http://package-proxy/src/contrib/lwgeom_0.2-1.tar.gz'
Content type 'application/x-tar' length 1908692 bytes (1.8 MB)
==================================================
downloaded 1.8 MB
* installing *binary* package ‘lwgeom’ ...
* DONE (lwgeom)
The downloaded source packages are in
‘/tmp/RtmpYqGuIx/downloaded_packages’
library(lwgeom)
Linking to liblwgeom 3.0.0beta1 r16016, GEOS 3.5.1, PROJ 4.9.2
mun_caquetá$area <- st_area(mun_caquetá)
mun_caquetá$km2 <- mun_caquetá$area/(1000000)
mun_caquetá$km2
Units: [m^2]
[1] 323.5200 935.3236 8841.8345 474.2438 1735.2031 721.2803
[7] 2023.9860 891.5957 1193.0877 223.3164 2733.4959 835.9698
[13] 18040.2569 49676.0412 1492.6313
ant_mun <- as(mun_caquetá, 'Spatial')
head(ant_mun)
An object of class "SpatialPolygonsDataFrame"
Slot "data":
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
bins <- c(0, 50, 100, 200, 300, 500, 1000, 2000, Inf)
pal <- colorBin("YlOrRd", domain = ant_mun$km2, bins = bins)
labels <- mun_caquetá$NAME_2
labels
[1] "Albania" "Belén de los Andaquies"
[3] "Cartagena del Chairá" "Curillo"
[5] "El Doncello" "El Paujíl"
[7] "Florencia" "La Montañita"
[9] "Milán" "Morelia"
[11] "Puerto Rico" "San José del Fragua"
[13] "San Vicente del Caguán" "Solano"
[15] "Valparaíso"
m <- leaflet(ant_mun) %>%
setView(-73.4, -0.1, 6) %>% addPolygons(
fillColor = ~pal(km2),
weight = 2,
opacity = 1,
color = "white",
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
leaflet() %>%
addProviderTiles(providers$Esri.WorldImagery, options= providerTileOptions(opacity = 0.99)) %>%
addPolygons(data = ant_mun, popup= ant_mun$NAME_2,
stroke = TRUE, fillOpacity = 0.25, smoothFactor = 0.25
)
leaflet() %>%
addTiles %>% #Add deafault OpenStreetMap map ties
addMarkers(lng=-73.628177, lat=4.148539, popup="Villavicencio")
foo <- leaflet() %>%
setView(lng =-73.628177, lat =4.148539, zoom = 10) %>%
addTiles()
foo %>% addProviderTiles("NASAGIBS.ModisTerraTRUEColorCR")
foo <- leaflet() %>%
setView(lng =-73.628177, lat =4.148539, zoom = 7) %>%
addTiles()
m %>% addProviderTiles("NASAGIBS.ViirsEarthAtNight2012")