My objective is to add a new calculated field to the output layer from a processing script.
This layer is created as follows:-
source = self.parameterAsSource(
parameters,
self.INPUT,
context
)
(sink, dest_id) = self.parameterAsSink(
parameters,
self.OUTPUT,
context,
source.fields(),
source.wkbType(),
source.sourceCrs()
)
I am then adding a feature to the sink layer from source in an iteration loop
for current, feature in enumerate(source.getFeatures()):
value = 1
#I want to add value to feature as an attribute, how??
sink.addFeature(feature, QgsFeatureSink.FastInsert)
How do I add the value attribute to the sink layer?
Should it be done when declaring sink?