Assign values to points according to a pattern
If you data is as organised as you say, creating the "tree column" with following expression for the field calculator should work:
CASE
WHEN $id%3=0 THEN 'Cashew'
WHEN $id%3=1 THEN 'Baobab'
ELSE 'Banana'
END
Short explanation: This checks whether the feature's ID is divisible by 3, and if not, what rest (%
is the modulo-operator) is left, then assigns the fitting tree-type. As ID starts with 0
, Cashew is assigned to all IDs with no rest.
Open the field calculator, select the function editor and make the content look like:
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def tree(value1, feature, parent):
trees=['Cashew','Baobab','Banana']
idx=value1%(len(trees)-1)
return(trees[idx])
Press "Save and load functions" then in the Expression tab, type
tree(fid)
If you want the easiest possible solutiuon, look at Erik's below, but it is less flexible if you want to add more types.