Hi @barrett_h, I think a general approach is to rename 'count' to the value of 'month' in the same record, and then aggregate the records grouped by 'locality'. An implementation example is:
Instead of renaming with the BulkAttributeRenamer, you can also use the AttributeCreator to create a new attribute whose name is equal to the value of 'month' and assign the value of 'count' to that. This may be easier to understand.
Here is another approach. Create a JSON document containing pairs of key (month) and value (count), and flatten it to extract the key/value pairs as attributes.
There is more than one way, but I usually use the BulkAttributeRenamer in a similar case.
Hope this helps.
Hi @barrett_h, I think a general approach is to rename 'count' to the value of 'month' in the same record, and then aggregate the records grouped by 'locality'. An implementation example is:
Instead of renaming with the BulkAttributeRenamer, you can also use the AttributeCreator to create a new attribute whose name is equal to the value of 'month' and assign the value of 'count' to that. This may be easier to understand.
Here is another approach. Create a JSON document containing pairs of key (month) and value (count), and flatten it to extract the key/value pairs as attributes.
There is more than one way, but I usually use the BulkAttributeRenamer in a similar case.
Hope this helps.
If you were familiar with Python scripting, the PythonCaller could also be an alternative of course.
# PythonCaller Script Example
class FeatureProcessor(object):
def __init__(self):
# {key=locaity : value=feature}
self.kv = {}
def input(self, feature):
loc = feature.getAttribute('locality')
mon = feature.getAttribute('month')
cnt = feature.getAttribute('count')
self.kv.setdefault(loc, feature).setAttribute(mon, cnt)
def close(self):
for feature in self.kv.values():
self.pyoutput(feature)
Hi @barrett_h, I think a general approach is to rename 'count' to the value of 'month' in the same record, and then aggregate the records grouped by 'locality'. An implementation example is:
Instead of renaming with the BulkAttributeRenamer, you can also use the AttributeCreator to create a new attribute whose name is equal to the value of 'month' and assign the value of 'count' to that. This may be easier to understand.
Here is another approach. Create a JSON document containing pairs of key (month) and value (count), and flatten it to extract the key/value pairs as attributes.
There is more than one way, but I usually use the BulkAttributeRenamer in a similar case.
Hope this helps.
Those are great suggestions @takashi! Thank you very much, I ended up going for the JSON idea as it provides so much flexibility.