2

我是使用 Python - Arcmap 的新手。

我的地图上有一个名称几乎相同的图层列表(bound3 到 bound50)

我想计算 MinimumBoundingGeometry_management。我发现了如何为单层做到这一点。

arcpy.MinimumBoundingGeometry_management("bound3","bound3ConvexHull","CONVEX_HULL","ALL")

相反,我想创建一个类似 matlab 样式的循环:

for i=3:1:50 arcpy.MinimumBoundingGeometry_management(boundi,boundiConvexHull,... "CONVEX_HULL","ALL") end

有人可以给我一个提示!

多谢

4

1 回答 1

3

你只需要为每个 i 构造字符串"boundi""boundiConvexHull"

而不是3:50(在 Matlab 中)你xrange(3,51)在 python 中做。您上去的原因51xrange(n)生成序列0:(n-1)(python 是基于 0 的,而 matlab 是基于 1 的)。

for i in xrange(3,51):
    arcpy.MinimumBoundingGeometry_management("bound%i" % i, "bound%iConvexHull" % i, ... )

我使用了 python 的字符串格式:"bound%i" % i是您在 matlab 中熟悉的 printf 类型函数的语法糖。

方便的链接:

于 2012-01-24T04:23:13.830 回答