spatial_nutrient: Spatialize nutrient fertilization plans

Description Usage Arguments Details Value

View source: R/spatial_nutrient.R

Description

Spatialization is performed bny fitting a variogram model to the nutrients fertilization plans and then performing ordinary kriging.

Usage

1
2
3
4
5
6
7
8
9
spatial_nutrient(
  sp_df,
  model = "auto",
  grid_spdf = NULL,
  bbox_buffer = 0L,
  spat_res = 5L,
  nutrient = "all",
  ...
)

Arguments

sp_df

a Spatial soil nutrients fertilization dataset

model

a character vector describing the variogram model type. Either "auto" or one of the available variogram models to gstat::vgm(), e.g. "Exp", "Sph", "Gau", "Mat". Specific model parameters may be passed to gstat::vgm() as named function arguments arguments. In "auto" the optimal variogram is chosen by automap::autofitVariogram(). Calling gstat::vgm() without a model argument returns a data.frame with available models.

grid_spdf

a sp::SpatialPoints() object grid with nutrient predictions locations. If NULL (default) then a point grid is built using sp_df bounding box and coordinate reference system, each point spatially distant by spat_res.

bbox_buffer

an integer value to enlarge (or shrink) the bounding box the default point grid is built in (i.e. when grid_spdf is set to NULL). Default to 0L, i.e. no effect on the bounding box.

spat_res

a positive number indicating the spatial resolution of the resulting spatial grid when grid_spdf is NULL. Default is 5 metres.

nutrient

a character vector detailing which nutrient spatialized fertilization plan to compute among "nitrogen", "phosphorus", and "potassium". Any combination of the three nutrients can be given or "all" (default) to compute all of them.

...

arguments that will be passed to gstat::vgm() or automap::autofitVariogram()

Details

The function returns a list of sp::SpatialPointsDataFrame() grids on the bounding box of the spatial soil nutrients fertilization dataset, as returned by demand_nutrient(). Each spatial grid can be readily plotted or rasterized.

Spatial coordinates must be passed as 'X' and 'Y' named columns in sp_df spatial table. This table should also containing either 'nitrogen', 'phosphorus', and 'potassium' named columns according to the nutrient plan to be spatialized passed as nutrient argument.

Value

a list with as many elements as nutrients given as nutrient parameter. Each element is a sp::SpatialPointsDataFrame().


mbask/fertplanspatial documentation built on July 5, 2020, 9:51 a.m.