https://github.com/brownag/grundo
Digital Soil Mapping (DSM) From The Ground Up!
https://github.com/brownag/grundo
Last synced: about 2 months ago
JSON representation
Digital Soil Mapping (DSM) From The Ground Up!
- Host: GitHub
- URL: https://github.com/brownag/grundo
- Owner: brownag
- License: cc0-1.0
- Created: 2023-01-09T00:17:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-10T16:24:50.000Z (over 2 years ago)
- Last Synced: 2025-02-08T08:47:09.734Z (4 months ago)
- Language: R
- Size: 712 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.R
- License: LICENSE.md
Awesome Lists containing this project
README
## ---- include = FALSE----------------------------------------------------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = requireNamespace("sp", quietly = TRUE)
)## ----example-------------------------------------------------------------------------------------------------------------
library(grundo)
library(terra)samples <- vect(system.file("extdata", "meuse.gpkg", package = "grundo"))
predictors <- rast(system.file("extdata", "meuse.grid.ex.tif", package = "grundo"))## to use classic `meuse` datasets from {sp} package
# data(meuse, package = "sp")
# data(meuse.grid, package = "sp")
# predictors <- rast(meuse.grid, crs = "EPSG:28992")
# samples <- vect(meuse, geom = c("x", "y"), crs = "EPSG:28992")## ----dependent-var-------------------------------------------------------------------------------------------------------
variable <- "om"## ----predictors-and-samples1---------------------------------------------------------------------------------------------
# remove observations that are missing organic matter %
samples <- samples[!is.na(samples[[variable]][[1]]), ]# visual inspection
plot(predictors[[3]])
points(samples, pch = "+", cex = 1)## ----predictors-and-samples2---------------------------------------------------------------------------------------------
names(predictors)names(samples)
## ----cubist-meuse--------------------------------------------------------------------------------------------------------
# cubist with {Cubist} + OK residuals
x <- grundo(
predictors = predictors,
samples = samples,
variable = variable,
model = "cubist",
vgm_model = "Exp"
)plot(x$result)
plot(sum(x$result[[1:2]]))## ----ranger-meuse--------------------------------------------------------------------------------------------------------
# random forest with {ranger} + OK residuals
y <- grundo(
predictors = predictors,
samples = samples,
variable = variable,
model = "ranger",
vgm_model = "Exp"
)plot(y$result)
plot(sum(y$result[[1:2]]))## ----meuse-ensemble------------------------------------------------------------------------------------------------------
plot(mean(c(sum(x$result[[1:2]]), sum(y$result[[1:2]]))))