An agricultural sprayer having spray nozzles 18 mounted along a boom 12 and lifting means 16 for varying the height of the boom relative to the ground, comprises optical scanning means 20 for detecting and measuring the height of the ground or of crop plants growing. Speed and/or position measuring means measure the instantaneous speed and/or position of the sprayer, and data processing means are linked to the optical scanning means and to the speed and/or position measuring means and configured to calculate a control boom height dynamically in accordance with the measured ground or crop plant. The speed and /or position measurement means may comprise a GPS receiver or an inertial measurement unit. The boom may comprise at least two sections and the lifting means may adjust the height of these sections independently.