Hello,
I would like to read all attributes for some specific fields and then compute some satistics.
I know that it is possible with multiple statistics calculators and feature mergers.
How can I do this inside a python caller?
Thanks
Hello,
I would like to read all attributes for some specific fields and then compute some satistics.
I know that it is possible with multiple statistics calculators and feature mergers.
How can I do this inside a python caller?
Thanks
Best answer by takashi
I sometimes implement a group-based processing applying this PythonCaller script frame work, in conjunction with a Sorter that sorts input features by Group By attribute.
# Assume all the features have been sorted by "_group_id" beforehand.
class FeatureProcessor(object):
def __init__(self):
self.groupId = None
self.features = [] # list of features
def input(self,feature):
id = feature.getAttribute('_group_id')
if id != self.groupId:
self.process()
self.groupId = id # Update current group ID.
self.features = [] # Reset the list of features.
self.features.append(feature)
def close(self):
self.process()
def process(self):
if not self.features:
return
#
# TODO: Process features in a group and output result.
#
If you need to perform really advanced statistics calculation, however, consider learning the R language and leveraging the RCaller.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.