createFunctionsForNorms
@svenvw/fdm-source / fdm-calculator/src / createFunctionsForNorms
Function: createFunctionsForNorms()
createFunctionsForNorms(
b_region
,year
):object
Defined in: fdm-calculator/src/norms/index.ts:7
Parameters
b_region
"NL"
year
"2025"
Returns
aggregateNormsToFarmLevel()
aggregateNormsToFarmLevel: (
input
) =>AggregatedNormsToFarmLevel
Aggregates the norm values from individual fields to the farm level. This function takes the output per field of the norm calculation, multiplies each norm by the field's area, and sums these values across all fields to provide total norms for the farm.
The result are three numbers (manure, nitrogen, phosphate) expressed as totals, not per hectare.
Parameters
input
InputAggregateNormsToFarmLevel
An array of field data, each containing field ID, area, and calculated norms.
Returns
An object containing the total aggregated norms for manure, nitrogen, and phosphate for the farm.
Example
const fieldData = [
{
b_id: "field1",
b_area: 10, // hectares
norms: {
manure: { normValue: 100, normSource: "Source A" }, // kg N/ha
nitrogen: { normValue: 150, normSource: "Source B" }, // kg N/ha
phosphate: { normValue: 50, normSource: "Source C" }, // kg P2O5/ha
},
},
{
b_id: "field2",
b_area: 5, // hectares
norms: {
manure: { normValue: 90, normSource: "Source A" }, // kg N/ha
nitrogen: { normValue: 140, normSource: "Source B" }, // kg N/ha
phosphate: { normValue: 45, normSource: "Source C" }, // kg P2O5/ha
},
},
];
const aggregatedNorms = aggregateNormsToFarmLevel(fieldData);
// aggregatedNorms will be:
// {
// manure: (100 * 10) + (90 * 5) = 1000 + 450 = 1450,
// nitrogen: (150 * 10) + (140 * 5) = 1500 + 700 = 2200,
// phosphate: (50 * 10) + (45 * 5) = 500 + 225 = 725,
// }
calculateNormForManure()
calculateNormForManure: (
input
) =>Promise
<DierlijkeMestGebruiksnormResult
> =getNL2025DierlijkeMestGebruiksNorm
Determines the 'gebruiksnorm' (usage standard) for nitrogen from animal manure for a given farm and parcel in the Netherlands for the year 2025.
This function implements the rules and norms specified by the RVO for 2025, taking into account derogation status and location within NV-gebieden.
Parameters
input
An object containing all necessary parameters for the calculation. See DierlijkeMestGebruiksnormInput for details.
Returns
Promise
<DierlijkeMestGebruiksnormResult
>
An object of type DierlijkeMestGebruiksnormResult
containing the determined
nitrogen usage standard (normValue
) and a normSource
string explaining the rule applied.
Remarks
The rules for 2025 are as follows:
- Standard Norm (No Derogation): If the farm does NOT have a derogation permit, the norm is 170 kg N/ha from animal manure.
- Derogation Norm (With Derogation): If the farm HAS a derogation permit:
- Inside Natura2000-Gebied: If the parcel is located in a Natura200-Gebied or within 100m of it, the norm is 170 kg N/ha from animal manure.
- Inside GWBG-Gebied: If the parcel is located in a GWBG Gebied or within 100m of it, the norm is 170 kg N/ha from animal manure.
- Inside NV-Gebied: If the parcel is located in a Nutriënt-Verontreinigd Gebied, the norm is 190 kg N/ha from animal manure.
- Outside NV-Gebied: If the parcel is NOT located in a Nutriënt-Verontreinigd Gebied, the norm is 200 kg N/ha from animal manure.
See
- RVO Hoeveel dierlijke mest landbouwgrond (official page)
- RVO Derogatie (official page)
- RVO Met nutriënten verontreinigde gebieden (NV-gebieden) (official page)
calculateNormForNitrogen()
calculateNormForNitrogen: (
input
) =>Promise
<GebruiksnormResult
> =getNL2025StikstofGebruiksNorm
Determines the 'gebruiksnorm' (usage standard) for nitrogen for a given cultivation based on its BRP code, geographical location, and other specific characteristics. This function is the primary entry point for calculating the nitrogen usage norm according to the Dutch RVO's "Tabel 2 Stikstof landbouwgrond 2025" and related annexes.
Parameters
input
An object of type NL2025NormsInput
containing all necessary data:
farm.is_derogatie_bedrijf
: A boolean indicating if the farm operates under derogation.field.b_centroid
: An object with the latitude and longitude of the field's centroid.cultivations
: An array of cultivation objects, from which thehoofdteelt
(main crop) will be determined.
Returns
Promise
<GebruiksnormResult
>
A promise that resolves to an object of type GebruiksnormResult
containing:
normValue
: The determined nitrogen usage standard in kilograms per hectare (kg/ha).normSource
: The descriptive name from RVO Table 2 used for the calculation.kortingDescription
: A description of any korting (reduction) applied to the norm. Returnsnull
if no matching standard or applicable norm can be found for the given input.
Throws
If the hoofdteelt
cultivation cannot be found or if geographical data
queries fail.
Remarks
The function follows a comprehensive, multi-step process to accurately determine the correct nitrogen norm:
-
Identify Main Crop (
hoofdteelt
): ThedetermineNL2025Hoofdteelt
function is called to identify the primary cultivation (b_lu_catalogue
) for the field based on the providedcultivations
array. This is the first step to narrow down the applicable nitrogen standards. -
Determine Geographical Context:
isFieldInNVGebied
: This asynchronous helper function is called to check if the field's centroid falls within a Nitraatkwetsbaar Gebied (NV-gebied). Fields in NV-gebieds often have stricter (lower) nitrogen norms.getRegion
: This asynchronous helper function determines the specific soil region (e.g., "zand" for sandy soil, "klei" for clay soil) based on the field's coordinates. Nitrogen norms can vary significantly by soil type. Both functions use efficient spatial queries to retrieve this information.
-
Match Nitrogen Standard Data: The
nitrogenStandardsData
(loaded from a JSON file) is filtered to find all entries (NitrogenStandard
objects) whoseb_lu_catalogue_match
array includes the identifiedb_lu_catalogue
of thehoofdteelt
. -
Refine by Variety (for Potatoes): If the
hoofdteelt
has a specificb_lu_variety
(e.g., for potatoes), the matching standards are further filtered. Potatoes can have "high" (varieties_hoge_norm
) or "low" (varieties_lage_norm
) nitrogen norms based on their variety. If a specific variety match is not found, it falls back to "overig" (other) potato norms if available. -
Select the Most Specific Standard: If multiple
NitrogenStandard
entries still match after initial filtering and variety-specific refinement, the function attempts to select the most specific one. This prioritization ensures that detailed rules (e.g., those withoutvariety_type
orsub_types
if a direct match is found) are applied correctly. -
Retrieve Applicable Norms: The
getNormsForCultivation
helper function is called with theselectedStandard
and other relevant parameters (variety, derogation status, cultivation end date). This function applies a hierarchy of rules (sub-type periods, variety-specific, derogation-specific) to return the preciseNormsByRegion
object for the cultivation. -
Calculate Final Norm Value: From the
applicableNorms
object, the function retrieves the specific norms for the determinedregion
. The finalnormValue
is then selected: if the field is in anis_nv_area
, thenv_area
norm is used; otherwise, thestandard
norm is applied. -
Apply "Korting" (Reduction): The
calculateKorting
function is called to determine if a reduction should be applied based on the previous year's cultivations and the field's region. The calculatedkortingAmount
is then subtracted from thenormValue
.
This detailed process ensures that the calculated nitrogen usage norm is accurate and compliant with RVO regulations, taking into account all relevant agricultural and geographical factors.
See
- RVO Tabel 2 Stikstof landbouwgrond 2025 - Official document for nitrogen norms.
- RVO Gebruiksnormen stikstof (official page) - General information on nitrogen and phosphate norms.
calculateNormForPhosphate()
calculateNormForPhosphate: (
input
) =>Promise
<FosfaatGebruiksnormResult
> =getNL2025FosfaatGebruiksNorm
Determines the 'gebruiksnorm' (usage standard) for phosphate for a given field based on its land type (grasland/bouwland) and soil phosphate condition, derived from P-CaCl2 and P-Al soil analysis values.
This function implements the "Tabel Fosfaatgebruiksnormen 2025" and the "Differentiatie fosfaatgebruiksnorm 2025" rules from RVO.
Parameters
input
An object containing all necessary parameters for the calculation. See FosfaatGebruiksnormInput for details.
Returns
Promise
<FosfaatGebruiksnormResult
>
An object of type FosfaatGebruiksnormResult
containing the determined
phosphate usage standard (normValue
) and the fosfaatKlasse
(the phosphate
class determined from the soil analysis). Returns null
if a norm cannot be determined.
Remarks
The function operates as follows:
- Determine Phosphate Class: The
getFosfaatKlasse
helper function is used to classify the soil's phosphate condition ('Arm', 'Laag', 'Neutraal', 'Ruim', 'Hoog') based on the provideda_p_cc
anda_p_al
values and whether it's grassland or arable land. This classification directly uses the lookup tables provided by RVO for 2025. - Retrieve Base Norm: The determined
fosfaatKlasse
is then used to look up the corresponding base phosphate norm from thefosfaatNormsData.json
file. - Apply Land Type: The specific norm for either
grasland
orbouwland
is selected from the base norm based on theis_grasland
input parameter. - Return Result: The function returns the final
normValue
and thefosfaatKlasse
.
See
- RVO Fosfaat landbouwgrond (official page)
- RVO Fosfaatdifferentiatie (official page, including tables for 2025)
collectInputForNorms()
collectInputForNorms: (
fdm
,principal_id
,b_id
) =>Promise
<NL2025NormsInput
> =collectNL2025InputForNorms
Collects all necessary input data from the FDM to calculate the Dutch (NL) norms for the year 2025.
This function orchestrates fetching data for a given farm, its fields, cultivations, and soil analyses, and structures it into a format suitable for the various NL 2025 norm calculation functions.
Parameters
fdm
FdmType
An initialized FdmType instance for data access.
principal_id
string
The ID of the principal initiating the data collection.
b_id
string
The unique identifier of the field for which to collect data.
Returns
Promise
<NL2025NormsInput
>
A promise that resolves to an NL2025NormsInput
object, containing all the
structured data required for the norm calculations.