【发布时间】:2015-08-06 18:02:07
【问题描述】:
我正在尝试将其制作成可在 ArcMap 中重复使用的地理处理工具,但我收到以下错误。我格式化 where_query 变量的方式似乎存在问题,但我似乎无法正确处理。
Traceback (most recent call last):
File "C:\ArcPy\mean_center_drift.py", line 19, in <module>
arcpy.Select_analysis(in_feature, year_out_name, where_query)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 84, in Select
raise e
ExecuteError: ERROR 000358: Invalid expression 1
Failed to execute (Select).
这是当前形式的代码。
import os
import arcpy
in_feature = arcpy.GetParameterAsText(0)
out_features = arcpy.GetParameterAsText(1)
origin_year = arcpy.GetParameterAsText(2)
field_name = arcpy.GetParameterAsText(3)
for x in range(10, 140, 10):
year_range = int(origin_year) + x
where_query = 'field_name' <= "{0}.format(year_range)"
year_out_name = os.path.join(out_features, "Years_{0}".format(x))
mean_out_name = os.path.join(out_features, "Mean_{0}".format(x))
arcpy.Select_analysis(in_feature, year_out_name, where_query)
arcpy.MeanCenter_stats(year_out_name, mean_out_name, "#", "#", "#")
您能提供的任何帮助将不胜感激!
【问题讨论】:
-
您可能还想在Geographic Information Systems 发帖——那里有很多 arcpy 人。
where_query看起来很可疑 - 你想在那里做什么? -
我正在尝试在 Select_analysis() 函数中的 where 子句的变量中定义输入。 - help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//…