autopredict: Autopredict numeric or factor type variables

Description Usage Arguments Details Author(s) See Also Examples

Description

Fits a spatial prediction model via the fit.gstatModel function (in the case of numeric variable), or some classification algorithm (factor-type variable), and generates predictions. By defaults uses machine learning method (random forest) as implemented in the ranger package.

Usage

1
2
3
## S4 method for signature 'SpatialPointsDataFrame,SpatialPixelsDataFrame'
autopredict(target, covariates, 
     auto.plot=TRUE, spc=TRUE, buffer.dist=TRUE, ...)

Arguments

target

object of class "SpatialPointsDataFrame" containing observations of the target variable

covariates

object of class "SpatialPixelsDataFrame"; spatial covariates

auto.plot

logical; specifies whether to immediately plot the data via the plotKML function

spc

logical; specifies whether to generate spatial predictive components

buffer.dist

logical; specifies whether to use buffer distances as covariates

...

other optional arguments that can be passed to fit.gstatModel

Details

For factor-type variables, classes with <5 observations are automatically removed from analysis. Generation of principal components via the spc function and buffer distances can be time-consuming for large rasters.

Author(s)

Tomislav Hengl

See Also

fit.gstatModel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
library(sp)
library(gstat)
library(ranger)
library(plotKML)
library(raster)

## Ebergotzen data set:
data(eberg)
## subset to 8%
eberg <- eberg[runif(nrow(eberg))<.08,]
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
data(eberg_grid)
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")

## predict sand content:
SNDMHT_A <- autopredict(eberg["SNDMHT_A"], eberg_grid,
   auto.plot=FALSE, rvgm=NULL)
plot(raster(SNDMHT_A$predicted["SNDMHT_A"]), col=SAGA_pal[[1]])

## predict soil types:
soiltype <- autopredict(eberg["soiltype"], eberg_grid, 
  auto.plot=FALSE)
## Not run: 
spplot(soiltype$predicted, col.regions=R_pal[[2]])
## most probable class:
eberg_grid$soiltype <- as.factor(apply(soiltype$predicted@data, 1, which.max))
levels(eberg_grid$soiltype) = names(soiltype$predicted@data)
spplot(eberg_grid["soiltype"])

## Meuse data set:
demo(meuse, echo=FALSE)
zinc <- autopredict(meuse["zinc"], meuse.grid[c("dist","ffreq")], 
  auto.plot=FALSE, rvgm=NULL)
spplot(zinc$predicted["zinc"])

## End(Not run)

GSIF documentation built on May 2, 2019, 5:44 p.m.

Related to autopredict in GSIF...