In order to study the dependence of the species richness on heterogeneity of the habitat, we introduce an extended model of annual plants which combines the features of the island model and of gradient heterogeneity resources. First, we consider a native population of plants living on a square lattice of linear size L. After equilibration of this native population, seeds of several different species j = 2, ..., k of annual plants invade the system; they compete among themselves and the native ones. The system is exposed to a one-dimensional water gradient, and each species is characterised by a tolerance to a surplus of water, τ (j). We study the influences of the properties of the gradient of the resource (GR) on the species richness (SR) present in the system. We have shown that the relation between GR and SR is not straightforward and that several cases could be distinguished: For a large class of control parameters, SR increases linearly with GR. However, when the values of the control parameters are such as to create wide inhabitable regions, the relation between SR and GR ceases to have a monotonic character. We have also demonstrated that the average species richness as a function of the resource availability has a hump shape. Our results can be simply explained within our model and are in agreement with several previous field and theoretical works.