如何使用Python在循环中通过查询的相应shape值来命名查询的输出shapefile?

问题描述 投票:0回答:1
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
for lyr in m.listLayers("POP_ACS17"):
   if lyr.supports("DEFINITIONQUERY"):
       for value in listnumbers.split(','):
           lyr.definitionQuery = "COLUMN=" + num
           output_path=r'C:/ArcGIS/Projects/Value_by_Value/'+ num
           arcpy.FeatureClassToShapefile_conversion('POP_ACS17',output_path)

如何根据查询结果在文件夹中创建shapefile名称,并且多次不使用相同名称“ POP_ACS17”?而是类似num +“ _POPACS17”等。当我键入

arcpy.FeatureClasstoShapefile_conversion('POP_ACS17', num + "_"+ outputh_path)

它不起作用。我收到错误消息

 ERROR 000732: Output Folder: Dataset C:/ArcGIS/Projects/Value_by_Value/1.0/1.0_PCT_POP_ACS17 does not exist or is not supported

我要做的只是用循环下划线中的相应值重命名我的输出,并且它已经给出的默认名称是'POP_ACS17'

所以我想要

1.0_POP_ACS17.shp in folder 1.0
2.0_POP_ACS17.shp in folder 2.0
3.0_POP_ACS17.shp in folder 3.0 

如果不是,则>

POP_ACS17_1.0 in folder 1.0
POP_ACS17_2.0 in folder 2.0
POP_ACS17_3.0 in folder 3.0    

依此类推...只要我知道怎么做就没关系。

aprx = arcpy.mp.ArcGISProject(“ CURRENT”)m = aprx.listMaps(“ Map”)[0] for m.listLayers(“ POP_ACS17”)中的lyr:如果lyr.supports(“ DEFINITIONQUERY”): listnumbers.split(',')中的值:...

python-3.x for-loop filepath shapefile arcpy
1个回答
0
投票

代替

© www.soinside.com 2019 - 2024. All rights reserved.