import arcpy polygonZ = r"C:\tmp\Testing.gdb\PolygonZ" rows = arcpy.SearchCursor(polygonZ) for row in rows: feature = row.SHAPE #get the geometry into variable partNum = 0 partCount = feature.partCount sumZ = 0.0 totalPntCount = 0 #feature can have multiple parts - first goes iteration through parts while partNum < partCount: part = feature.getPart(partNum) #the output is Array of points pnt = part.next() #take first point from Array of points pntNum = 0 pntCount = part.count #iterate through points (first point is doubled as last point - last point is excludec) while pntNum < (pntCount - 1): valueZ = pnt.Z sumZ += valueZ pnt = part.next() pntNum += 1 totalPntCount += 1 partNum += 1 meanZ = sumZ/totalPntCount print meanZ del rows, row
import arcpy, csv, os, sys, traceback from arcpy import env arcpy.env.overwriteOutput = True ##try: #track segment FC segZ = "C:/Documents and Settings/h6e6v/My Documents/Leader_Work/PTC_DATA/Test/MissingZTest_1.gdb/segs_noZvalue_test" pntZ = "C:/Documents and Settings/h6e6v/My Documents/Leader_Work/PTC_DATA/Test/MissingZTest_1.gdb/pnts_withZvalue_test" descs = arcpy.Describe(segZ) shapefieldnames = descs.ShapeFieldName descp = arcpy.Describe(pntZ) shapefieldnamep = descp.ShapeFieldName newPoint = arcpy.Point() segUC = arcpy.UpdateCursor(segZ) for seg in segUC: bXYZ = seg.getValue(shapefieldnames) partNum = 0 for part in bXYZ: part_list = [] for item in bXYZ.getPart(partNum): if item: x = str(item.X) ix = x[:14] y = str(item.Y) iy = y[:14] pnts = arcpy.UpdateCursor(pntZ) iz = item.Z for pnt in pnts: pXYZ = pnt.getValue(shapefieldnamep) point = pXYZ.labelPoint pointX = point.X pointY = point.Y pointZ = point.Z if ix == str(pointX): if iy == str(pointY): print item.ID print ix+" = "+str(pointX) print iy+" = "+str(pointY) print item.Z print str(pointZ) else: pass else: pass else: pass
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.