fme字段重命名
1.一般解决方案
有两种方式:转换器attributerenamer,bulkattributerenamer
2.特殊情况
当要求将多个表的多个字段进行重命名,且不同的表中同一旧字段需要重命名为不同的新字段,或不同旧字段需要重新命名为统一旧字段(这种情况可用转换器)
2.1 针对不同表中同一旧字段重命名为不同新字段的问题的解决方案
class AttributeRenamebyList(object):
def __init__(self):
pass
def input(self,feature):
NameandAlias= feature.getAttribute('_list{}.NameAndAlias')
#_list{}.NameAndAlias中存储了新旧字段名称,并采用空格分割,例如'oldname newname'
for attr in enumerate(NameandAlias):
name=attr.split(' ')[0]
alias=attr.split(' ')[1]
#分割新旧字段
value='@RenameAttributes(FME_STRICT,'+alias+','+name+')'
#设置FME的rename函数语句
feature.performFunction(value)
#运行FME函数,将旧字段按照list中与新字段的对应关系,进行重命名
self.pyoutput(feature)
def close(self):
pass
2.2 Reference
Processing Behavior : | Feature-Based |
---|
A Feature-Based Transformer is one which processes one feature at a time, in isolation from all other features.
2.3 链接
FME factory and function documentation
FME community (rename feature attribute with python)