Este notebook presenta un anĆ”lisis de interpolación espacial del Carbono OrgĆ”nico del Suelo (SOC) en el municipio del Meta, Colombia. El anĆ”lisis se realiza siguiendo la guĆa acadĆ©mica del profesor IvĆ”n Lizarazo, en la Facultad de Ciencias Agrarias de la Universidad Nacional de Colombia. Se utilizan mĆ©todos como IDW y Kriging Ordinario.
library(sf)
library(gstat)
library(leaflet)
library(leafem)
library(terra)
library(stars)
library(automap)
# Leer shapefile del municipio
municipio <- st_read("C:/Users/vidam/Downloads/Municipio Meta.gpkg")
## Reading layer `mgn_adm_mpio_grafico' from data source
## `C:\Users\vidam\Downloads\Municipio Meta.gpkg' using driver `GPKG'
## Simple feature collection with 29 features and 11 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -74.93335 ymin: 1.617732 xmax: -71.07753 ymax: 4.899101
## Geodetic CRS: WGS 84
# Leer puntos de SOC recortados al municipio
samples <- st_read("C:/Users/vidam/Downloads/socmeta.gpkg")
## Reading layer `puntos_vectoriales' from data source
## `C:\Users\vidam\Downloads\socmeta.gpkg' using driver `GPKG'
## Simple feature collection with 2339260 features and 1 field
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -74.9318 ymin: 1.621266 xmax: -71.0795 ymax: 4.897252
## Geodetic CRS: WGS 84
# Asegurar sistema de referencia espacial comĆŗn
samples <- st_transform(samples, crs = st_crs(municipio))
# Filtrar puntos que estƔn dentro del municipio
samples_meta <- samples[municipio, ]
# Reducir a 2000 puntos aleatoriamente
set.seed(123)
samples <- samples[sample(1:nrow(samples), 2000), ]
# Revisar estructura y resumen
nrow(samples)
## [1] 2000
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 0.0 107.0 104.9 155.0 871.0
# Histograma
hist(samples$SOC.PUNTOS, main = "Distribución de SOC (%)",
xlab = "SOC", col = "lightblue")
# Redondear valores
samples$SOC.PUNTOS <- round(samples$SOC.PUNTOS, 2)
pal <- colorNumeric(
palette = c("#E1F5C4", "#EDE574", "#F9D423", "#FC913A", "#FF4E50"),
domain = samples$SOC.PUNTOS
)
leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addPolygons(data = municipio, color = "gray", weight = 1, fillOpacity = 0.2) %>%
addCircleMarkers(data = samples, radius = 1.5, label = ~SOC.PUNTOS,
color = ~pal(SOC.PUNTOS), fillOpacity = 1, stroke = FALSE) %>%
addLegend("bottomleft", pal = pal, values = samples$SOC.PUNTOS,
title = "SOC (%)", opacity = 0.9)