ExecuteError:错误000561:所选层的关系无效。无法执行(SelectLayerByLocation)

2024-04-29 05:56:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个代码,在我的nhlroster.shp功能类中,nhl球员只需要打这三个位置中的一个:leftFeild、rightFeild、Center,所有球员都必须出生在瑞典。我的arcpy.SelectLayerByLocation\u管理:运行时错误:对象:执行工具中的错误

import arcpy

arcpy.env.workspace = "C:/Users/jessi/Desktop/CPSUGeog485/project3_2021"
cntryFc = "Countries_WGS84.shp"
leftFeild = "LW"
rightFeild = "RW"
Center = "C"
cntryFeild = "CNTRY_name"
cntry = "Sweden"

#Select only players from target country
whereClause = cntryFeild + " =  '" + cntry + "'"
cntryLayer = arcpy.SelectLayerByAttribute_management(cntryFc, "NEW_SELECTION", whereClause)

#Create Loop for Target Positions
positionList = (leftFeild, rightFeild, Center) 
for plyrPositions in positionList:
    playerQuery = "plyrPosition = '" + plyrPositions + "'"
#Narrow down players born in sweden who play target positions
plyrLayer = arcpy.SelectLayerByLocation_management(cntryLayer, "Contains", positionList)

Tags: target错误center球员playersarcpyshpcntry