Skip to content

Commit

Permalink
Removed deps with geoR
Browse files Browse the repository at this point in the history
  • Loading branch information
thengl committed Jun 6, 2022
1 parent 1bde9b3 commit da3abb5
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 245 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: landmap
Title: Automated Spatial Prediction using Ensemble Machine Learning
Version: 0.0.13
Version: 0.0.14
Authors@R: person("Tomislav", "Hengl", email = "[email protected]", role = c("aut", "cre"))
Description: Functions and tools for spatial interpolation and/or prediction of environmental variables (points to grids)
based on using Ensemble Machine Learning with geographical distances. Package also provides access to Global
Expand All @@ -20,7 +20,6 @@ Imports:
mlr,
parallelMap,
sp,
geoR,
plyr,
rgdal,
gdalUtils,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export(model.data)
export(search.landgis)
export(train.spLearner.matrix)
exportMethods(buffer.dist)
exportMethods(fit.vgmModel)
exportMethods(getSpatialTiles)
exportMethods(sample.grid)
exportMethods(spc)
Expand Down
140 changes: 0 additions & 140 deletions R/fit.vgmModel.R

This file was deleted.

32 changes: 6 additions & 26 deletions R/train.spLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param predict.type Prediction type 'prob' or 'response',
#' @param super.learner Ensemble stacking model usually \code{regr.lm},
#' @param subsets Number of subsets for repeated CV,
#' @param lambda Target variable transformation for geoR (0.5 or 1),
#' @param lambda Target variable transformation lambda (0.5 or 1),
#' @param cov.model Covariance model for variogram fitting,
#' @param subsample For large datasets consider random subsetting training data,
#' @param parallel Initiate parellel processing,
Expand Down Expand Up @@ -51,36 +51,16 @@ train.spLearner.matrix <- function(observations, formulaString, covariates, SL.l
}
if(is.numeric(Y)){
if(missing(super.learner)){ super.learner <- "regr.lm" }
## variogram fitting:
if(lambda==1){
ini.var <- stats::var(log1p(Y), na.rm = TRUE)
}
if(lambda==0.5){
ini.var <- stats::var(Y, na.rm = TRUE)
}
## strip buffer distances from vgm modeling
rm.n = unlist(sapply(c("rX_*$","rY_*$","layer.*$"), function(i){grep(pattern=utils::glob2rx(i), names(covariates))}))
if(length(rm.n)>0){
covs.vgm <- names(covariates)[-rm.n]
} else {
covs.vgm <- names(covariates)
}
formulaString.vgm <- stats::as.formula(paste(tv, "~", paste(covs.vgm, collapse="+")))
suppressWarnings( rvgm <- fit.vgmModel(formulaString.vgm, rmatrix = observations, predictionDomain = covariates[covs.vgm], lambda = lambda, ini.var = ini.var, cov.model = cov.model, subsample = subsample) )
} else {
message("Skipping variogram modeling...", immediate. = TRUE)
if(missing(super.learner)){ super.learner <- "classif.glmnet" }
points <- observations
sp::coordinates(points) <- stats::as.formula(paste("~", paste(xyn, collapse = "+"), sep=""))
sp::proj4string(points) <- covariates@proj4string
rvgm <- list(vgm=list(practicalRange=NA, cov.model="nugget", lambda=NA), observations=points)
}
points <- observations
sp::coordinates(points) <- stats::as.formula(paste("~", paste(xyn, collapse = "+"), sep=""))
sp::proj4string(points) <- covariates@proj4string
rvgm <- list(vgm=list(practicalRange=NA, cov.model="nugget", lambda=NA), observations=points)
if(missing(cell.size)){
## automatically determine cell.size using fitted range
cell.size <- rvgm$vgm$practicalRange/2
if(is.na(cell.size) | cell.size < (covariates@grid@cellsize[[1]]*2)){
cell.size <- abs(diff(covariates@bbox[1,]))/20
}
cell.size <- abs(diff(covariates@bbox[1,]))/40
}
## spatial ID for CV:
if(is.null(id)){
Expand Down
1 change: 0 additions & 1 deletion R/tune.spLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#' \donttest{
#' library(mlr)
#' library(ParamHelpers)
#' library(geoR)
#' library(xgboost)
#' library(kernlab)
#' library(ranger)
Expand Down
73 changes: 0 additions & 73 deletions man/fit.vgmModel.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/train.spLearner.matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/tune.spLearner-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da3abb5

Please sign in to comment.