本文整理汇总了Python中arcrest.agol.FeatureLayer.addFeature方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureLayer.addFeature方法的具体用法?Python FeatureLayer.addFeature怎么用?Python FeatureLayer.addFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcrest.agol.FeatureLayer
的用法示例。
在下文中一共展示了FeatureLayer.addFeature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from arcrest.agol import FeatureLayer [as 别名]
# 或者: from arcrest.agol.FeatureLayer import addFeature [as 别名]
#.........这里部分代码省略.........
proxy_port=proxy_port,
proxy_url=proxy_url,
initialize=True)
areaResults = fl.query(**{'where':"1=1",'outSR':'102100','out_fields':assignmentAreaNameField,'returnGeometry':False,'returnCentroid':True})
for area in areaResults:
arDict = area.asDictionary
areaNameToID[arDict['attributes'][assignmentAreaNameField]] = arDict['centroid']
#Get the workers
item = portalAdmin.content.getItem(itemId=workforceProjectID)
itemData = item.itemData()
if 'workers' in itemData:
fl = FeatureLayer(
url=itemData['workers']['url'],
securityHandler=fst.securityhandler,
proxy_port=proxy_port,
proxy_url=proxy_url,
initialize=True)
workersResults = fl.query(where="1=1",out_fields='OBJECTID, NAME',returnGeometry=False)
for worker in workersResults:
workerNameToID[worker.get_value('name')] = worker.get_value('OBJECTID')
if 'dispatchers' in itemData:
fl = FeatureLayer(
url=itemData['dispatchers']['url'],
securityHandler=fst.securityhandler,
proxy_port=proxy_port,
proxy_url=proxy_url,
initialize=True)
dispatcherResults = fl.query(where="1=1",out_fields='OBJECTID, NAME',returnGeometry=False)
for dispatcher in dispatcherResults:
dispatcherNameToID[dispatcher.get_value('name')] = dispatcher.get_value('OBJECTID')
if 'assignments' in itemData:
features = []
fl = FeatureLayer(
url=itemData['assignments']['url'],
securityHandler=fst.securityhandler,
proxy_port=proxy_port,
proxy_url=proxy_url,
initialize=True)
print(fl.deleteFeatures(where="1=1"))
with open(csvPath) as csvfile:
reader = UnicodeDictReader(csvfile)
for row in reader:
json_string={}
json_string['geometry'] = {}
centroidInfo = areaNameToID[row[areaCol].strip()]
json_string['geometry']['x'] = centroidInfo['x']
json_string['geometry']['y'] = centroidInfo['y']
json_string['attributes'] ={}
json_string['attributes']['workerId'] = workerNameToID[row[workerCol].strip()]
json_string['attributes']['description'] = row[descriptionCol]
json_string['attributes']['notes'] = row[notesCol]
json_string['attributes']['assignmentType'] = assignmentType
json_string['attributes']['status'] = status
json_string['attributes']['dispatcherId'] = dispatcherNameToID[row[supervisorCol].strip()]
features.append(Feature(json_string=json_string))
results = fl.addFeature(features=features)
if 'error' in results:
print ("Error in response from server: %s" % results['error'])
else:
if results['addResults'] is not None:
featSucces = 0
for result in results['addResults']:
if 'success' in result:
if result['success'] == False:
if 'error' in result:
print ("Error info: %s" % (result['error']))
else:
featSucces = featSucces + 1
print ("%s features added to %s" % (featSucces,fl.name))
else:
print ("0 features added to %s /n result info %s" % (fl.name,str(results)))
except (common.ArcRestHelperError) as e:
print ("error in function: %s" % e[0]['function'])
print ("error on line: %s" % e[0]['line'])
print ("error in file name: %s" % e[0]['filename'])
print ("with error message: %s" % e[0]['synerror'])
if 'arcpyError' in e[0]:
print ("with arcpy message: %s" % e[0]['arcpyError'])
except:
line, filename, synerror = trace()
print ("error on line: %s" % line)
print ("error in file name: %s" % filename)
print ("with error message: %s" % synerror)