## ----Loading soil rfiles------------------------------------------------------ library(agrodata) library(terra) SOC <- reagro_data("TZA_ORC") Kex <- reagro_data("TZA_EXK") pH <- reagro_data("TZA_PH") ## ----compute soil nutrient supply--------------------------------------------- library(Rquefts) supply <- rast(pH, nlyr=3) values(supply) <- nutSupply1(pH, SOC, Kex, Polsen=15) supply ## ----clamp-------------------------------------------------------------------- supply <- clamp(supply, 1, Inf) names(supply) <- c("Ns", "Ps", "Ks") supply plot(supply) ## ----WY----------------------------------------------------------------------- Ya <- reagro_data("TZA_YW") ## ----set up a q model--------------------------------------------------------- library(Rquefts) maize <- quefts_crop("Maize") fertilizer <- list(N=64, P=20, K=0) q <- quefts(crop=maize, fert=fertilizer) ## ----Running------------------------------------------------------------------ yield <- rast(Ya) values(yield) <- run(q, supply, Ya) plot(yield)