auto_interpolate_points: Automatically interpolates point values

Description Usage Arguments Value Author(s) Examples

View source: R/auto_interpolate_points.R

Description

This function tries to automatically interpolate points

Usage

1
2
3
4
5
6
7
8
auto_interpolate_points(
  sp_points,
  aim_variable,
  outputfile,
  co_variables = FALSE,
  procedure = c("ked", "rfk", "ok", "idw"),
  show_rmse = TRUE
)

Arguments

sp_points

SpatialPointsDataframe containing the aim variable and if "ked" should be applied the covariables

aim_variable

Character string with the name of the aim variable

outputfile

SpatialPointsDataframe, SpatialGridDataFrame or raster which should be filled with predictions; requires covariables for "ked" (if two values are given in a vector a raster is created with the resolution given by the values)

co_variables

default = FALSE, vector of covariables if needed

procedure

default = c("ked","rfk,"ok","idw"); vector containing the interpolation technic to be used; all methods are tested and the method with the lowest RMSE is used for the interpolation; KED = Kriging With external Drift; RFK = Random Forest Kriging; OK = Ordinary Kriging; IDW = Inverse distance Weighting

show_rmse

default = TRUE, should the RMSE values derived by loocv_interpolate_points be displayed?

Value

interpolated point values as sp or raster file depending on outputfile

Author(s)

Wolfgang Hamer

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
library(magrittr)
library(dplyr)
library(sp)
library(raster)

# Download example data
shdat <- download_statewide_hourly_station_data(state = "Schleswig-Holstein", coord = TRUE)

# Select data of specific Time / Date
da_sel <- shdat %>% filter(DateTime == sort(unique(shdat$DateTime))[5])

# Create spatial dataset
da_sel_sp <- SpatialPointsDataFrame(da_sel[,c("lon", "lat")],
                                    da_sel,
                                    proj4string = CRS("+init=epsg:4326"))

# Transform to projected (m based!) system
da_sel_sp <- spTransform(da_sel_sp, CRS("+init=epsg:25832"))

air_mean <- download_dwd_raster(parameter = "air_temperature_mean", period = "1961-1990", month = 17, crop=da_sel_sp)

da_sel_sp <- raster::extract(air_mean,da_sel_sp,sp=TRUE)

# Application of function for point data result
myintpoints <- auto_interpolate_points(sp_points = da_sel_sp,
                                       aim_variable = "Temperature",
                                       outputfile = air_mean,
                                       co_variables = c("air_temp_mean_1961.1990_17"))
plot(myintpoints)

whamer/papros documentation built on Feb. 6, 2021, 8:54 a.m.