diff --git a/src/crop/cropmodels.jl b/src/crop/cropmodels.jl index 4030860c1e57559b3d1152991bea791d005b7ac9..4a67eba781a98fe6b60880b546429076124e096d 100644 --- a/src/crop/cropmodels.jl +++ b/src/crop/cropmodels.jl @@ -3,6 +3,8 @@ ### Functions for switchable crop models. ### +using StatsBase: mode + """ initfields!(cropmodel, cropfile, growthfile) @@ -61,6 +63,12 @@ function initfields!(model::SimulationModel) end end end + + # Adjust soil type to most common soil type of the pixels + # belonging to a farmplot + for fp in model.farmplots + fp.soiltype = mode(map(p -> model.landscape[p[1], p[2]].soiltype, fp.pixels)) + end @info "Initialised $(length(model.farmplots)) farm plots." end