AnsweredAssumed Answered

How to get the MIN and Max from a while loop - python

Question asked by dabera on Aug 3, 2012
Latest reply on Sep 9, 2013 by ferialferial
Hi Eveyone,

I got the following python code to get the geometry(X, Y, Z) of a polyline feature. It can print all the values. But what I am looking is that, how do we get the MIN and MAX values for Z -value which is an elevation value in my case; and pass it as a variable. I am new to python and having trouble to figure it out. The code is as follows. Thanks in advance for your help.

Daniel A.

# Import native arcgisscripting module # import arcgisscripting  # Create the geoprocessor object # gp = arcgisscripting.create(9.3)  infc = gp.GetParameterAsText(0)    # Identify the geometry field # desc = gp.Describe(infc) shapefieldname = desc.ShapeFieldName  # Create search cursor # rows = gp.SearchCursor(infc) row = rows.Next()  # Enter while loop for each feature/row # while row:     # Create the geometry object     #     feat = row.GetValue(shapefieldname)      # Print the current multipoint's ID     #     print "Feature " + str(row.getvalue(desc.OIDFieldName)) + ":"     partnum = 0      # Count the number of points in the current multipart feature     #     partcount = feat.PartCount      # Enter while loop for each part in the feature (if a singlepart feature     # this will occur only once)     #     while partnum < partcount:         # Print the part number         #         print "Part " + str(partnum) + ":"         part = feat.GetPart(partnum)         pnt = part.Next()         pntcount = 0          # Enter while loop for each vertex         #         while pnt:             # Print x,y coordinates of current point             #             print pnt.x, pnt.y, pnt.z             pnt = part.Next()             pntcount += 1              # If pnt is null, either the part is finished or there is an              #   interior ring             #             if not pnt:                  pnt = part.Next()                 if pnt:                     print "Interior Ring:"         partnum += 1      row = rows.Next()

Outcomes