名称:name' select_pour_point'未定义
尝试为每个倒数设置变量时,我会收到此错误。这是一个
cur_point = select_pour_point(pour_points,name_field,name)
nameRorr:name'select_pour_point'未定义
帮助!
import shedtools as st
# Directories
SCRATCH = "C:\\SCRATCH"
OUT_FOLDER = "C:\\WATERSHEDS"
# inputs
POUR_POINTS = "C:\\Hawaii_DEM\\Hawaii.shp"
FLOW_DIRECTION = "C:\\Hawaii_DEM\\hawaii_flwdir"
STATS_RASTER = "C:\\HawaiiRFGrids_mm\\RF_MM_BI_Ann"
RASTER_NAME = "stats"
NAME_FIELD = "Id"
STATISTICS = "MEAN"
with arcpy.da.SearchCursor(POUR_POINTS, NAME_FIELD) as cursor:
for point in cursor:
name = str(point[0])
print "Working on pour point %s" % (name)
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
shed_raster = make_watershed_raster(FLOW_DIRECTION, cur_point, name, SCRATCH)
我收到的错误是:
Traceback (most recent call last):
File "C:\\exercise_5.py", line 30, in <module>
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
NameError: name 'select_pour_point' is not defined
第30行是:
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
I am receiving this error when trying to setup variables for each pour point. It is a
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
NameError: name 'select_pour_point' is not defined
HELP!
import shedtools as st
# Directories
SCRATCH = "C:\\SCRATCH"
OUT_FOLDER = "C:\\WATERSHEDS"
# inputs
POUR_POINTS = "C:\\Hawaii_DEM\\Hawaii.shp"
FLOW_DIRECTION = "C:\\Hawaii_DEM\\hawaii_flwdir"
STATS_RASTER = "C:\\HawaiiRFGrids_mm\\RF_MM_BI_Ann"
RASTER_NAME = "stats"
NAME_FIELD = "Id"
STATISTICS = "MEAN"
with arcpy.da.SearchCursor(POUR_POINTS, NAME_FIELD) as cursor:
for point in cursor:
name = str(point[0])
print "Working on pour point %s" % (name)
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
shed_raster = make_watershed_raster(FLOW_DIRECTION, cur_point, name, SCRATCH)
Error I am receiving is:
Traceback (most recent call last):
File "C:\\exercise_5.py", line 30, in <module>
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
NameError: name 'select_pour_point' is not defined
Line 30 is:
cur_point = select_pour_point(POUR_POINTS, NAME_FIELD, name)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用
导入SHEDTOOLS作为ST
导入您的shedtools.py脚本。因此,您需要前缀select_pour_point
和make_watershed_polygon
带有st
与您的错误无关,而是打开您的
arcpy.da.searchcursor
使用with
,以确保使用后再次关闭。另外,您也可以使用以下方式使用以下方式使用以下方面的功能以:
从shedtools导入您的函数,而不是将功能从shedtools导入您的功能,请select_pour_point,make_watershed_raster
,如果这样做,则无需前缀:
You import your shedtools.py script using
import shedtools as st
. Therefore, you need to prefixselect_pour_point
andmake_watershed_polygon
withst.
:st.select_pour_point(...)
Not related to your error BUT open your
arcpy.da.SearchCursor
usingwith
to make sure it is closed again after using.Alternatively, instead of prefixing your functions with
st.
, you could also import your functions using:from shedtools import select_pour_point, make_watershed_raster
If you do so, no prefixing is necessary: