Bridges the constant-rate output of N_balance() / calculate_N_fertilization()
or scheda_N() with the spatial NDVI-based variable-rate estimators of NFert
(estimate_N_rate_from_calibration_curve() and
estimate_N_rate_from_holland_schepers()).
Usage
variable_rate_N(
ndvi_raster,
n_dose,
method = c("calibration", "holland"),
envelope = 0.25,
minN = NULL,
maxN = NULL,
mas_cap = NULL,
plot = FALSE
)Arguments
- ndvi_raster
A
raster::RasterLayerwith NDVI (0–1), or aRasterBrick/RasterStack(layerNDVIif present, otherwise the first layer).- n_dose
Numeric. Field-average N dose (kg/ha) from
N_balance()+calculate_N_fertilization(),scheda_N()$dose_final, or any custom target.- method
Either
"calibration"(default, two-point linear) or"holland"(Holland & Schepers sufficiency index).- envelope
Numeric in (0, 1). Half-amplitude of the dose range around
n_dosefor the calibration method. Default 0.25 (i.e. minN = 0.75 * n_dose, maxN = 1.25 * n_dose).- minN, maxN
Optional explicit override of the envelope (in kg/ha).
- mas_cap
Numeric or NULL. If provided, caps the per-pixel rate so it never exceeds the MAS limit (e.g. from
get_MAS()).- plot
Logical, passed to the underlying estimator. Default FALSE.
Value
A list with:
- rate_raster
RasterLayerof N rate per pixel (kg/ha).- mean_kg_ha
Mean rate over non-NA pixels (kg/ha).
- min_kg_ha, max_kg_ha
Min and max rate over non-NA pixels.
- n_dose_input
The input field-average N dose.
- method
The method used.
Details
Two integration patterns are supported:
Calibration curve (
method = "calibration"): the agronomic balance determines the target field-average dose; the function then derives aminN/maxNenvelope around it (default +/- 25%) and applies the linear NDVI-driven calibration (low NDVI = more N, high NDVI = less N).Holland & Schepers (
method = "holland"): the agronomic balance is used as the base N rate of the H&S sufficiency-index algorithm.
The output preserves the field-average dose computed by the balance: the
raster of variable rates integrates (mean) to approximately the input
n_dose, ensuring the agronomic constraint (MAS, ZVN) is respected.
Examples
if (FALSE) { # \dontrun{
library(raster)
library(NFert)
# NDVI raster
data(s2.rast)
ndvi <- s2.rast
# 1) Compute agronomic dose with the balance
bal <- N_balance(expected_yield_tons_ha = 6,
crop = "Grano duro (pianta intera)",
ccp = "Spring-summer crop 100-130 days",
sand = 15.5, clay = 18.5,
Ntot = 1.5, SOM = 2, CN = 7.73,
oxygen_availability = "Normal",
winter_rain = 150, start_spring_rain = 0,
prev_crop = "Maize stalks removed",
source = "None", fertorg_frequency = "every year",
location = "Plain adjacent to urbanized areas",
forg_quantity = 0)
n_dose <- calculate_N_fertilization(bal) # ~142 kg/ha
# 2) Spatialise via NDVI calibration
vr <- variable_rate_N(ndvi, n_dose = n_dose, method = "calibration",
mas_cap = get_MAS("Grano duro (pianta intera)")$N_max)
raster::plot(vr$rate_raster)
vr$mean_kg_ha
} # }