Python 我需要根据点的位置填充一个字段

Python 我需要根据点的位置填充一个字段,python,arcpy,Python,Arcpy,我有5个总部,需要将离他们最近的客户分配到离他们最近的总部。这将打印出一个字典,其中包含距离每个总部最近的点或客户的所有OBJECTID。键是总部号码,值是客户ID。如何使用最接近的销售团队填充客户层中的字段?我有每个点应该去哪里的结果,但我不知道如何填充customer层中的字段。您可以创建一个额外的更新光标,根据字典中的项目和值循环并更新行 以arcpy.da.updateCursors(fc,字段)作为光标的: #对于每行,评估油井产量值并更新油井等级 对于光标中的行: if(row[0

我有5个总部,需要将离他们最近的客户分配到离他们最近的总部。这将打印出一个字典,其中包含距离每个总部最近的点或客户的所有OBJECTID。键是总部号码,值是客户ID。如何使用最接近的销售团队填充客户层中的字段?我有每个点应该去哪里的结果,但我不知道如何填充customer层中的字段。

您可以创建一个额外的更新光标,根据字典中的项目和值循环并更新行

以arcpy.da.updateCursors(fc,字段)作为光标的
:
#对于每行,评估油井产量值并更新油井等级
对于光标中的行:
if(row[0]>=0和row[0]From:“鼓励链接到外部资源,但请在链接周围添加上下文,以便您的其他用户了解它是什么以及为什么存在。始终引用重要链接的最相关部分,以防外部资源无法访问或永久脱机。”
in_fc = "C:/Users/Olivia/Desktop/Desktop Developement/Module3_Lab_Data.gdb/Customers"

nearest_dict = dict()

with arcpy.da.SearchCursor(in_fc, ["OID@", "NEAR_FID"]) as rows:
    for row in rows:
        nearest_id = row[0] #get OID value
        input_id = row[1] #get Near_ID value
       
        if input_id in nearest_dict:
            #if a dict key already exists, append it
            nearest_dict[input_id].append(nearest_id)
            
        else:
            #if not, create new list with near_ID and add to dictionary
            nearest_dict[input_id]= [nearest_id]
            
print(nearest_dict)
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    # For each row, evaluate the WELL_YIELD value and update WELL_CLASS
    for row in cursor:
        if (row[0] >= 0 and row[0] <= 10):
            row[1] = 1