Application of near-infrared spectroscopy to agriculture and forestry