Pergunta

I'm new in using Python - Arcmap.

I have on my map a list of layers with the nearly same name (bound3 to bound50)

I want to calculate the MinimumBoundingGeometry_management. I found out how to do it for one single layer.

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

Instead I'd like to create a loop like in matlab style:

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

can someone give me an hint !

thanks a lot

Foi útil?

Solução

You just have to construct the strings "boundi" and "boundiConvexHull" for each i.

Instead of 3:50 (in Matlab) you do xrange(3,51) in python. The reason you go up to 51 is that xrange(n) generates the sequence 0:(n-1) (python is 0-based whereas matlab is 1-based).

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

I've made use of python's string formatting: "bound%i" % i is syntactic sugar for printf-type functions that you are familiar with in matlab.

Handy links:

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top