使用edit_feature函数时,一个特性不显示所做的编辑

77
1
3周前
标签(3)
ColeHowell
通过
新贡献者II

标题说明了一切。我在一家水务公司工作,正在开发一个系统,从我们的SCADA系统中获取流量数据,并将数据导入GIS,用于泄漏检测。具体来说,我现在正在做的是将正向和反向流放在我的区域表托管功能层的这些字段中。我遇到的问题是,当我运行脚本时,“P10”仪表的字段没有更新,而我正在使用的其余仪表工作得很好。我只是需要一些帮助故障排除,因为我是新的使用API。我附加了我写的函数来做这个。

def update_zone_meters(dictionary): gis = gis ("url", "username", "password") portal_item = gis.content。Get ('item id') meter_layer = portal_item。Layers [0] meter_fset = meter_layer.query() meter_features = meter_fset。在meter_features中的meter特性:edit = meter #print(edit.attributes['constrno2']) if(编辑。#print(dictionary[edit.attributes['constrno2']+'F'])Attributes ['forward_flow'] = dictionary[编辑]。attributes['constrno2']+'F'] #print(edit.attributes['forward_flow']) elif编辑。attributes['constrno2'] == 'P10':编辑。Attributes ['forward_flow'] = dictionary[编辑]。[' constrno2 ']]编辑属性。属性['reverse_flow'] = 0.0否则:继续if(编辑。attributes['constrno2'] + 'R') in dictionary: edit。属性['reverse_flow'] = dictionary[编辑]。attributes['constrno2'] + 'R'] else:继续meter_layer.edit_features(updates=[edit])
0荣誉
1回复
Clubdebambos
通过
临时贡献者II

@ColeHowell

可能是elif编辑。attributes['constrno2'] == 'P10'从不被执行。

试一试

def update_zone_meters(dictionary): gis = gis ("url", "username", "password") portal_item = gis.content。Get ('item id') meter_layer = portal_item。Layers [0] meter_fset = meter_layer.query() meter_features = meter_fset。在meter_features中的meter特性:edit = meter #print(edit.attributes['constrno2']) if(编辑。#print(dictionary[edit.attributes['constrno2']+'F'])Attributes ['forward_flow'] = dictionary[编辑]。attributes['constrno2']+'F'] #print(edit.attributes['forward_flow']) else:继续## EDITED HERE到if/else if编辑。attributes['constrno2'] == 'P10':编辑。Attributes ['forward_flow'] = dictionary[编辑]。[' constrno2 ']]编辑属性。属性['reverse_flow'] = 0.0否则:继续if(编辑。attributes['constrno2'] + 'R') in dictionary: edit。属性['reverse_flow'] = dictionary[编辑]。attributes['constrno2'] + 'R'] else:继续meter_layer.edit_features(updates=[edit])
~规划我的退休之路
0荣誉