import arcgisscripting gp = arcgisscripting.create(9.3) infc = "path to input features" dsc = gp.Describe(infc) shapefieldname = dsc.ShapeFieldName rows = gp.SearchCursor(infc) row = rows.Next() while row: feat = row.getValue(shapefieldname) partnum = 0 partcount = feat.PartCount # iterate through each part of a multipart feature while partnum < partcount: poly = feat.GetPart(partnum) poly_area = poly.Area partnum += 1 row = rows.Next() del row del rows
import arcgisscripting gp = arcgisscripting.create(9.3) infc = r"Z:\Test.gdb\MultipartPolygon" singlePartFC = r"in_memory\SinglePart" gp.MultipartToSinglepart_management(infc,singlePartFC) dsc = gp.Describe(singlePartFC) shapefieldname = dsc.ShapeFieldName rows = gp.SearchCursor(singlePartFC) row = rows.Next() while row: feat = row.getValue(shapefieldname) poly_area = feat.Area print poly_area row = rows.Next() del row, rows
# area of multiparts import arcgisscripting gp = arcgisscripting.create(9.3) infc = "C:/path.gdb/multipolyfc" dsc = gp.Describe(infc) shapefieldname = dsc.ShapeFieldName rows = gp.SearchCursor(infc) #,"multipart = 2") row = rows.Next() while row: feat = row.getValue(shapefieldname) partnum = 0 partcount = feat.PartCount partArea = 0 cumArea = 0 print partcount ,feat.area # iterate through each part of a multipart feature while partnum < partcount: arrayPoly = feat.GetPart(partnum) # iterate through each vertex of the array # use old pre-computer Double Difference Area survey trick pt = arrayPoly.next() x0 = pt.x y0 = pt.y pt = arrayPoly.next() partArea = 0 while pt: partArea += (pt.x - x0) * (pt.y + y0) x0 = pt.x y0 = pt.y pt = arrayPoly.next() partnum += 1 partArea = partArea / 2.0 print partnum,partArea cumArea += partArea print "count %d,cum %f, feat %f diff (%12.8f) " % (partcount, cumArea,feat.area ,(feat.area - cumArea)/100) # break row = rows.Next() del row del rows
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.